Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Littleodie914

macrumors 68000
Original poster
Jun 9, 2004
1,813
8
Rochester, NY
Howdy fellow programmers! :)

I've got an app on the iPhone that integrates with Apple's Address Book, but I'm wondering if there's a way to save/load the ABRecordRef's to/from disk. I'm currently doing the following:

Code:
# For the initWithCoder:
self.people = (CFMutableArrayRef)([[NSMutableArray alloc] initWithArray:[coder decodeObjectForKey:@"AssignmentPeople"]]);

#For the encodeWithCoder
NSArray *arrayToSave = (NSArray *)self.people;	
[coder encodeObject:arrayToSave forKey:@"AssignmentPeople"];

Since CFArrays and NSArrays are toll-free bridged, the array conversion isn't an issue. I'm getting this error when writing to disk though, which leads me to believe there's an issue serializing the individual ABRecordRef's inside:

Code:
2008-06-29 22:07:30.863 iProcrastinate Mobile[2265:20b] *** -[NSCFType encodeWithCoder:]: unrecognized selector sent to instance 0x1a9930
2008-06-29 22:07:30.870 iProcrastinate Mobile[2265:20b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFType encodeWithCoder:]: unrecognized selector sent to instance 0x1a9930'

From reading that error message, does that sound like it's the issue? It's the only CFType-ish thing that I'm encoding, so I can't think of anything else that might be causing the problem.

If it is the problem, what other way should I be using to save those record types? :confused:
 

Littleodie914

macrumors 68000
Original poster
Jun 9, 2004
1,813
8
Rochester, NY
Hmm... I had a bit more time to debug it this morning, and I'm becoming more and more sure that's the problem, based on the debugger trace when the error occurred. So I think my question still is, how can you encode/decode CFType objects? I've googled all over the place, and there's very little documentation. :(
 

Attachments

  • Picture 1.png
    Picture 1.png
    73.5 KB · Views: 241

Littleodie914

macrumors 68000
Original poster
Jun 9, 2004
1,813
8
Rochester, NY
I'm at work right now, but I think when I get home I'm going to switch over from storing the actual ABPersonRef's to storing the RecordID's. That way I can avoid all the complicated data management, and then if a person changes outside of the app, the changes will be reflected inside. :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.