Re: Archiving ABPerson
Re: Archiving ABPerson
- Subject: Re: Archiving ABPerson
- From: Scott Ahten <email@hidden>
- Date: Fri, 7 May 2004 15:15:39 -0400
Vince [and Aaron],
I had tried that earlier, but had problems converting the data back
into a ABPerson.
Being new to Objective-C, I failed to realize
- (id)initWithVCardRepresentation:(NSData *)vCardData;
was a instance message, not at class message. It's working fine now.
I guess this means I need to release my ABPerson instance, since I
allocated it instead of the ABPerson class.
ABPerson * person = [ABPerson alloc];
[person initWithVCardRepresentation:cardData];
Thanks,
- Scott
On May 7, 2004, at 1:51 PM, Vince DeMarco wrote:
On May 7, 2004, at 10:21 AM, Scott Ahten wrote:
Hello everyone,
I'm trying to create a keyed archive that contains a NSArray of
ABPersons. I am archiving the array so it can transmitted across a
network to multiple users. At the moment, I'm just trying to archive
an ABPerson. My test code looks something like this...
ABAddressBook * ab = [ABAddressBook sharedAddressBook];
ABPerson * person = [ab me];
NSMutableData *representationToSend;
NSKeyedArchiver *archiver;
representationToSend = [NSMutableData data];
archiver = [[NSKeyedArchiver alloc]
initForWritingWithMutableData:representationToSend];
[archiver encodeObject:person forKey:@"abPerson"];
[archiver finishEncoding];
[archiver release];
This code returns the following error...
2004-05-07 12:43:02.037 Picture Sharing[3501] *** -[ABPerson
encodeWithCoder:]: selector not recognized
2004-05-07 12:43:02.037 Picture Sharing[3501] Exception raised during
posting of notification. Ignored. exception: *** -[ABPerson
encodeWithCoder:]: selector not recognized
Checking the headers, I found that ABPerson does not implement the
NSCoding interface. I assume lack of archive support is intentional
due to issues with it's implementation. Since I do not have the
source for ABPerson class, is it possible to extend or modify it to
support Archiving?
Any examples or resources would be greatly appreciated.
If you really want to do this then create a vcard and save that off to
the disk instead of doing this. ABRecords do not support Archiving.
use these methods on ABPerson instead
- (id)initWithVCardRepresentation:(NSData *)vCardData;
// Create a person from a vCard
- (NSData *)vCardRepresentation;
// Returns nil if vCardData is nil or not a valid vCard
Then instead of sending the archive just send the NSData of the
vcard around.
vince
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
- - - - -
:: email@hidden
::
http://www.pixelfreak.net
- - - - -
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.