Question about direct vs accessor....PLEASE IGNORE...WILL NOT HAPPEN AGAIN :-) ..APOLOGIES
Question about direct vs accessor....PLEASE IGNORE...WILL NOT HAPPEN AGAIN :-) ..APOLOGIES
- Subject: Question about direct vs accessor....PLEASE IGNORE...WILL NOT HAPPEN AGAIN :-) ..APOLOGIES
- From: Michael de Haan <email@hidden>
- Date: Sun, 25 Oct 2009 05:22:55 -0700
Surprisingly, I could find no reference to this issue.
In the archives, there seems to be, lately, the consensus ( I hope)
that direct ivar access is preferred in 2 methods ie init and dealloc.
This would seem to imply that initWithCoder/encodeWithCoder should
also use direct ivar access, but I have seen **both** used in
reputable sources.
So, from Apple's docs on archiving this:
- (void)encodeWithCoder:(NSCoder *)coder {
[super encodeWithCoder:coder];
[coder encodeObject:mapName forKey:@"MVMapName"];
[coder encodeFloat:magnification forKey:@"MVMagnification"];
[coder encodeObject:legendView forKey:@"MVLegend"];
[coder encodeConditionalObject:auxiliaryView forKey:@"MVAuxView"];
}
and from the binding examples on mmalc's page, this: ( I understand
that the method is deprecated)
- (NSData *)dataRepresentationOfType:(NSString *)aType
{
// create an archive of the collection and its attributes
NSKeyedArchiver *archiver;
NSMutableData *data = [NSMutableData data];
archiver = [[NSKeyedArchiver alloc]
initForWritingWithMutableData:data];
[archiver encodeObject:self.name forKey:@"name"];
[archiver encodeObject:self.collectionDescription
forKey:@"collectionDescription"];
[archiver encodeObject:self.collection forKey:@"collection"];
[archiver finishEncoding];
return data;
}
Is this just 6 of one and half dozen of the other?
Thanks.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
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