• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem Archiving/Un-archiving Custom Objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem Archiving/Un-archiving Custom Objects


  • Subject: Re: Problem Archiving/Un-archiving Custom Objects
  • From: Dave <email@hidden>
  • Date: Thu, 21 Jan 2016 23:22:47 +0000

> On 21 Jan 2016, at 23:04, Quincey Morris <email@hidden> wrote:
>
> On Jan 21, 2016, at 13:47 , Dave <email@hidden <mailto:email@hidden>> 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 (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Problem Archiving/Un-archiving Custom Objects
      • From: Quincey Morris <email@hidden>
References: 
 >How to save a Dictionary Network to a plist file? (From: Dave <email@hidden>)
 >Re: How to save a Dictionary Network to a plist file? (From: Jens Alfke <email@hidden>)
 >Problem Archiving/Un-archiving Custom Objects (From: Dave <email@hidden>)
 >Re: Problem Archiving/Un-archiving Custom Objects (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Problem Archiving/Un-archiving Custom Objects
  • Next by Date: Re: 32-bit / 64-bit roadmap
  • Previous by thread: Re: Problem Archiving/Un-archiving Custom Objects
  • Next by thread: Re: Problem Archiving/Un-archiving Custom Objects
  • Index(es):
    • Date
    • Thread