Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 29, 2008, 10:00 PM   #1
Littleodie914
macrumors 68000
 
Littleodie914's Avatar
 
Join Date: Jun 2004
Location: Rochester, NY
Using NSCoding with ABRecordRefs?

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?
Littleodie914 is offline   0 Reply With Quote
Old Jun 30, 2008, 06:44 AM   #2
Littleodie914
Thread Starter
macrumors 68000
 
Littleodie914's Avatar
 
Join Date: Jun 2004
Location: 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.
Attached Thumbnails
Click image for larger version

Name:	Picture 1.png
Views:	17
Size:	73.5 KB
ID:	121711  
Littleodie914 is offline   0 Reply With Quote
Old Jun 30, 2008, 07:18 AM   #3
Littleodie914
Thread Starter
macrumors 68000
 
Littleodie914's Avatar
 
Join Date: Jun 2004
Location: 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.
Littleodie914 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
NSCoding/NSUserDefaults nashyo iPhone/iPad Programming 5 Jun 25, 2012 05:41 AM

Forum Jump

All times are GMT -5. The time now is 11:22 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC