> On 21 Jan 2016, at 23:04, Quincey Morris 
> <quinceymor...@rivergatesoftware.com> wrote:
> 
> On Jan 21, 2016, at 13:47 , Dave <d...@looktowindward.com 
> <mailto: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.
> 

Yes, I came to that conclusion too and I added a initWithIndexPath method to an 
NSIndexPath Category and it works!

I was manually copying the dictionaries and arrays anyway - [xxxxx mutableCopy];

I did that and Bang it Crashed about, but this time with another bug which was 
easy to find since malloc guard caught it this time, that one was a flakey 
method for converting an NSString “xx.yy.zz" type string an Array of 
NSUInteger’s to call initWithIndexs with!

Fixed that one and now it work!

Thanks a lot Jens and Qunicey………

One quick question, I’m relying of the copy attribute for the NSString’s, do I 
need to change these to do a [xxxxxxx copy] too or is NSString OK?

All the Best
Dave
 
_______________________________________________

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