Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would cause my (strong) declared property to become nil behind my back?

Using ARC, I have a declared property of the following form:

@property (nonatomic, strong) MyClass * instanceName;

I set this property in three places - and I've added breakpoints to all three places.

I reference this property in a number of places.

As I step through my code, the property gets set, and none of the other two places where the property is getting set get called. (As expected).

However, at some point, the value of this property is becoming nil.

I've added a dealloc method to my class, with an NSLog, and a breakpoint - but it never gets called (so it's not like this is getting treated like a zeroing weak reference).

I'm baffled as to why my "strong" property would ever become nil without my causing it to do so.

Any advice would be appreciated.

Thanks

like image 307
Steve Avatar asked Oct 14 '11 19:10

Steve


1 Answers

The simple answer is that you are causing it to do so. You simply do not yet know how.

At some point after the ivar has been accessed, it should show up in your debug window with an "i" in front of it. Right-click on it and select "Watch..." You'll get a breakpoint every time the memory is modified.

like image 198
Rob Napier Avatar answered Nov 15 '22 18:11

Rob Napier