Problem Archiving/Un-archiving Custom Objects
Problem Archiving/Un-archiving Custom Objects
- Subject: Problem Archiving/Un-archiving Custom Objects
- From: Dave <email@hidden>
- Date: Thu, 21 Jan 2016 21:47:44 +0000
Hi,
I’ve got it working using NSCoding for now and I can review to later.
I have one crashing problem though, I’m getting a crash when one of the properties in my LTWNodeInfo is dealloc. It’s an NSIndexPath class, the rest seem to be ok. i’m wondering if it is to do with the way in which I’m creating/copying it:
@property (nonatomic,copy) NSIndexPath* pNodeIndexPath;
in initWithCoder:
self.pNodeIndexPath = [theCoder decodeObjectForKey:@"pNodeIndexPath”];
in encodeWithCoder:
[theCoder encodeObject:self. pNodeIndexPath forKey:@"pNodeIndexPath”];
in copyWithZone:
myObjectCopy. pNodeIndexPath = self. pNodeIndexPath; //Copy Attribute on Property
In order to work around it, I added an extra property:
@property (nonatomic,copy) NSString* pNodeIndexPathString;
Added to: initWithCoder:
self.pNodeIndexPathString = [theCoder decodeObjectForKey:@"pNodeIndexPathString”];
myIndexPath = [NSIndexPath newIndexPathWithPathString:self.pUIElementInfoIndexPathString];
self.pUIElementInfoIndexPath = myIndexPath;
Added to: encodeWithCoder:
[theCoder encodeObject:self. pNodeIndexPathString forKey:@"pNodeIndexPathString”];
and removed the encodeObject: self.pNodeIndexPath
in copyWithZone:
myObjectCopy. pNodeIndexPath = self. pNodeIndexPath; //Copy Attribute on Property
myObjectCopy. pNodeIndexPathString = self. pNodeIndexPathString; //Copy Attribute on Property
But I still get a crash on the dealloc of pNodeIndexPath.
in dealloc:
self.pNodeIndexPath = nil;
Anyone have any ideas what I’m doing wrong?
Thanks in Advance
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