On Jan 21, 2016, at 13:47 , Dave <d...@looktowindward.com> wrote:
> 
> myObjectCopy. pNodeIndexPath = self. pNodeIndexPath;                  //Copy 
> Attribute on Property

You have to be careful, depending on what’s already happened. If the object was 
copied with NSCopyObject, which might have happened in NSObjet’s copyWithZone 
method even if you didn’t call it directly, instance variables will contain 
valid but unretained pointers. Because you’re assigning to a property, the 
existing underlying instance variable will have its retain count decremented, 
which probably isn’t the right thing to do.

Your copyWithZone method is more like an init method than a regular method. In 
general, like in inits, you will want to assign directly to instance variables 
rather than use property setters. In addition, you may have to deal manually 
with retain counts. 

Yes, copyWithZone is a potential nightmare. In many cases, it’s easier not to 
copy anything really, but to create a new object whose instance variables you 
set up in a proper ‘initAsCopyOf:’ method that follows normal init conventions.

_______________________________________________

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