Septiadi Agus
Septiadi Agus

Reputation: 1775

How can this simple code fail assertion?

    PO(self);
    PO(_locationManager.delegate);
    PO([CLLocationHandler singleton]);
    _locationManager = [[CLLocationManager alloc] init];
    _locationManager.delegate = self;
    PO(self);
    PO(_locationManager.delegate);
    NSAssert(_locationManager.delegate==self,@"They are meant for each other");

So this code works in simulator and in most iPhone. There is one magical iPhone belonging to my biz partner that I can't debug program with.

If I run the installed program directly the code will yield this:

��

<Warning>: *** -[NSKeyedUnarchiver initForReadingWithData:]: data is NULL
<Warning>: self: <CLLocationHandler: 0x1f8df560>
<Warning>: _locationManager.delegate: (null) <Warning>: [CLLocationHandler singleton]: <CLLocationHandler: 0x1f8df560>
<Warning>: self: <CLLocationHandler: 0x1f8df560>
<Warning>: _locationManager.delegate: <RwXSxTb_DelegateProxy: 0x1e594d00>
<Warning>: *** Assertion failure in -[CLLocationHandler additionalInitialization], /business/Dropbox/badgers/BadgerNew/CLLocationHandler.m:251
<Error>: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'They are meant for each other'

What the hell is delegateProxy?

Upvotes: 0

Views: 77

Answers (2)

hamstergene
hamstergene

Reputation: 24439

There is no guarantee that reading from property will return exactly the same value.

Properties are syntactic sugar for calling getter and setter methods, and those methods can do anything.

It seems that in your case, -[CLLocationHandler setDelegate:] wraps the value in a proxy. Try comparing objects with isEqual: instead, many proxies will handle that correctly.

Upvotes: 2

Dipak Narigara
Dipak Narigara

Reputation: 1806

May be the device in which you are debugging is JB(Jail Break).

So, you are unable to debug in that device.

Upvotes: 3

Related Questions