So I have this custom object i made called 'Box', it's throwing the error for that one. Inside of my NSDictionary is...
box = [[Box alloc] initWithHeight:20 height:40];
wrap.dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:numberInt, kInt, numberShort, kShort, numberLong, kLong, numberFloat, kFloat, numberDouble, kDouble, numberBool, kBool, nsString, kString, nsDate, kDate, box, @"keybox", nil];
Notice the box object that I created up top and added in the NSDictionary at the very end. Before when the box wasn't in there, everything worked fine, but when I added the custom object 'Box', it couldn't save anymore.
- (void) saveDataToDisk:(NSMutableDictionary *)dictionaryForDisk
{
NSMutableData *data = [NSMutableData data];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc]initForWritingWithMutableData:data];
//Encode
[archiver setOutputFormat:NSPropertyListBinaryFormat_v1_0];
[archiver encodeObject:dictionaryForDisk forKey:@"Dictionary_Key"];
[archiver finishEncoding];
[data writeToFile:[self pathForDataFile] atomically:YES];
}
- (NSString *) pathForDataFile {
NSArray* documentDir = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString* path = nil;
if (documentDir)
{
path = [documentDir objectAtIndex:0];
}
return [NSString stringWithFormat:@"%@/%@", path, @"data.bin"];
}
This was the error
-[Box encodeWithCoder:]: unrecognized selector sent to instance 0x4e30d60
2011-11-11 11:56:43.430 nike[1186:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Box encodeWithCoder:]: unrecognized selector sent to instance 0x4e30d60'
*** Call stack at first throw:
Any help would be greatly appreciated!!!!