I just wrote some Objective-C++ code. It's basically just a regular Obj-C 
class, but makes some C++-style calls in its methods.

Anyway, I added an NSMutableData* ivar to my class, and set it with

        mInputBuffer = [NSMutableData data];

in one of the methods. Subsequent accesses, however, have resulted in it being 
deallocated, even though I never set mInputBuffer to NULL anywhere.

I changed the code to refer to it via a strong property, and it's fine.

I thought ARC worked the same in both cases (that is, retained the object on 
assignment and kept it around until the last reference was gone, even if via a 
regular ivar)

A bit of googling confirms this, so I'm wondering what I've done wrong.

-- 
Rick




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to