The JKDictionary class is private to JSONKit and should not be used in this fashion - objective-c

This is a followup question to this
In short, I'm making my app iOS 4.3 compatible and using the AFNetworking class version 0.10.1 that supports iOS 4 in my app.
This line self.responseJSON = AFJSONDecode(self.responseData, &error); gives me the error bellow. I'm not really familiar with JSON and trying to figure out what this error means.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** - [JKDictionary allocWithZone:]: The JKDictionary class is private to JSONKit and should not be used in this fashion.'
*** Call stack at first throw:
(
0 CoreFoundation 0x006ef5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x018e6313 objc_exception_throw + 44
2 CoreFoundation 0x006a7ef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x006a7e6a +[NSException raise:format:] + 58
...
...
26 libdispatch_sim.dylib 0x02888289 _dispatch_call_block_and_release + 16
27 libdispatch_sim.dylib 0x0288acb4 _dispatch_queue_drain + 250
28 libdispatch_sim.dylib 0x0288b2c2 _dispatch_queue_invoke + 49
29 libdispatch_sim.dylib 0x0288b593 _dispatch_worker_thread2 + 261
30 libsystem_c.dylib 0x90093b24 _pthread_wqthread + 346
31 libsystem_c.dylib 0x900956fe start_wqthread + 30
The error is from JSONKit.m:
+ (id)allocWithZone:(NSZone *)zone
{
#pragma unused(zone)
[NSException raise:NSInvalidArgumentException format:#"*** - [%# %#]: The %# class is private to JSONKit and should not be used in this fashion.", NSStringFromClass([self class]), NSStringFromSelector(_cmd), NSStringFromClass([self class])];
return(NULL);
}
With iOS 5 the app is using the line self.responseJSON =[NSJSONSerialization JSONObjectWithData:self.responseData options:0 error:&error]; that works great but ofcourse I can't use this in iOS 4 because NSJSONSerialization isn't supported.

I ended up replacing the problematic line with this self.responseJSON = [[CJSONDeserializer deserializer] deserialize:self.responseData error:&error];
Used a different class (TouchJSON) just for that line but it works great now.

Related

*** Assertion failure in -[AppDelegate createDatabaseExecutableFile]

I have application and in application delegate i have code for copy the db file into document folder but it's not working i don't know why because it was working before, and giving following error, please take a look and hope you can find something. Thanks
// Creates a writable copy of the bundled default database in the application Documents directory.
- (void) createDatabaseExecutableFile {
// First, test for existence.
BOOL _successDB;
BOOL _successConfig;
NSFileManager* _fileManager = [NSFileManager defaultManager];
NSError* _error;
NSArray* _paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString* _documentsDirectory = [_paths objectAtIndex:0];
NSString* _writableDBPath = [_documentsDirectory stringByAppendingPathComponent:#"turfnutritiontool_ver.db"];
NSString* _writableConfigPath = [_documentsDirectory stringByAppendingPathComponent:#"Configuration.plist"];
_successDB = [_fileManager fileExistsAtPath:_writableDBPath];
_successConfig = [_fileManager fileExistsAtPath:_writableConfigPath];
if (_successDB && _successConfig) {
return;
}
// The writable database does not exist, so copy the default to the appropriate location.
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:#"turfnutritiontool_ver.db"];
NSString *defaultConfigPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:#"Configuration.plist"];
_successDB = [_fileManager copyItemAtPath:defaultDBPath toPath:_writableDBPath error:&_error];
_successConfig = [_fileManager copyItemAtPath:defaultConfigPath toPath:_writableConfigPath error:&_error];
if (!_successDB || !_successConfig) {
NSAssert1(0, #"Failed to create writable database file with message '%#'.", [_error localizedDescription]);
}
}
This is the error:
2012-04-02 13:52:01.162 TurfNutritionTool_ver_5.1[2379:b903] *** Assertion failure in -[AppDelegate createDatabaseExecutableFile], /Development/TurfNutritionTool_IOS_5.1/TurfNutritionTool/AppDelegate.m:188
2012-04-02 13:52:01.165 TurfNutritionTool_ver_5.1[2379:b903] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Failed to create writable database file with message 'The operation couldn’t be completed. File exists'.'
*** Call stack at first throw:
(
0 CoreFoundation 0x0179a5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x018ee313 objc_exception_throw + 44
2 CoreFoundation 0x01752ef8 +[NSException raise:format:arguments:] + 136
3 Foundation 0x011fc3bb -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 TurfNutritionTool_ver_5.1 0x00003fef -[AppDelegate createDatabaseExecutableFile] + 831
5 TurfNutritionTool_ver_5.1 0x00003486 -[AppDelegate application:didFinishLaunchingWithOptions:] + 86
6 UIKit 0x009f9c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
7 UIKit 0x009fbd88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
8 UIKit 0x00a06617 -[UIApplication handleEvent:withNewEvent:] + 1533
9 UIKit 0x009feabf -[UIApplication sendEvent:] + 71
10 UIKit 0x00a03f2e _UIApplicationHandleEvent + 7576
11 GraphicsServices 0x01e21992 PurpleEventCallback + 1550
12 CoreFoundation 0x0177b944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
13 CoreFoundation 0x016dbcf7 __CFRunLoopDoSource1 + 215
14 CoreFoundation 0x016d8f83 __CFRunLoopRun + 979
15 CoreFoundation 0x016d8840 CFRunLoopRunSpecific + 208
16 CoreFoundation 0x016d8761 CFRunLoopRunInMode + 97
17 UIKit 0x009fb7d2 -[UIApplication _run] + 623
18 UIKit 0x00a07c93 UIApplicationMain + 1160
19 TurfNutritionTool_ver_5.1 0x00002ddd main + 125
20 TurfNutritionTool_ver_5.1 0x00002d55 start + 53
21 ??? 0x00000001 0x0 + 1
)
terminate called throwing an exception(lldb)
It says "file exists". Isn't that enough of a clue?
From the NSFileManager docs:
If a file with the same name already exists at dstPath, this method aborts the copy attempt and returns an appropriate error.
By the way, you should check the error after each copy, not once at the end because if an error occurs on the first copy, and the second copy, you'll lose the error information from the first copy.

Error using AVAudioRecorder

I'm making this voice recording app, but for some reason it won't let me use this delete method without crashing:
-(void)deleteCurrentFiles {
if(recorder != nil) {
if([recorder isRecording]) {
[recorder stop];
}
[recorder release];
recorder = nil;
[self performSelector:#selector(resetTotalTimeLabel) withObject:nil afterDelay:1.0];
}
if(player != nil) {
if([player isPlaying]) {
[player stop];
}
[player release];
player = nil;
currentTime = 0;
timeSlider.value = 0;
[self performSelector:#selector(resetCurrentTimeLabel) withObject:nil afterDelay:0.1];
}
if(commentRecorder != nil) {
if([commentRecorder isRecording]) {
[commentRecorder stop];
}
}
}
The declarations of these instances:
AVAudioRecorder *recorder;
AVAudioRecorder *commentRecorder;
AVAudioPlayer *player;
In resetTotalTimeLabel and resetCurrentTimeLabel there is no referance to / usage of the recorders/player.
The error I get is:
-[__NSArrayI finishedRecording]: unrecognized selector sent to instance 0x1b3ba0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI finishedRecording]: unrecognized selector sent to instance 0x1b3ba0'
*** Call stack at first throw:
(
0 CoreFoundation 0x35f08c7b __exceptionPreprocess + 114
1 libobjc.A.dylib 0x30186ee8 objc_exception_throw + 40
2 CoreFoundation 0x35f0a3e3 -[NSObject(NSObject) doesNotRecognizeSelector:] + 98
3 CoreFoundation 0x35eaf467 ___forwarding___ + 506
4 CoreFoundation 0x35eaf220 _CF_forwarding_prep_0 + 48
5 CoreFoundation 0x35ea3f79 -[NSObject(NSObject) performSelector:withObject:] + 24
6 Foundation 0x33fd3e6d __NSThreadPerformPerform + 272
7 CoreFoundation 0x35ebc8d1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
8 CoreFoundation 0x35e8cecd __CFRunLoopDoSources0 + 384
9 CoreFoundation 0x35e8c6f9 __CFRunLoopRun + 264
10 CoreFoundation 0x35e8c50b CFRunLoopRunSpecific + 226
11 CoreFoundation 0x35e8c419 CFRunLoopRunInMode + 60
12 GraphicsServices 0x35261d24 GSEventRunModal + 196
13 UIKit 0x3386557c -[UIApplication _run] + 588
14 UIKit 0x33862558 UIApplicationMain + 972
15 App Name 0x00002959 main + 80
16 App Name 0x00002904 start + 40
)
terminate called after throwing an instance of 'NSException'
It actually seems to happen to the recorder after this method is called.. So is there anything I should add to this method to make it work?
Any thoughts are greatly appriciated!
sending a message to an object which does not respond to it at a strange point in time is a good indication of a reference count imbalance. run your app with zombies enabled in Instruments. reproduce the crash and see if it is a zombie.

Get iTunes Artwork for Current Song with ScriptingBridge

I have been trying to figure out how to get the iTunes artwork for the currently playing song with scripting bridge. I have gotten to a point where it works for some songs, but for others, I get a SIGABRT. I'm not sure what the issue could be, so any help would be greatly appreciated. Here is what I have so far:
iTunesApplication * iTunes = [SBApplication applicationWithBundleIdentifier:#"com.apple.iTunes"];
NSImage *songArtwork;
iTunesTrack *current = [iTunes currentTrack];
iTunesArtwork *artwork = (iTunesArtwork *)[[[current artworks] get] lastObject];
if(artwork != nil)
songArtwork = [artwork data];
else
songArtwork = [NSImage imageNamed:#"Image.tiff"];
NSMenuItem *artworkMenuItem = [[NSMenuItem alloc] initWithTitle:#"" action:NULL keyEquivalent:#""];
[songArtwork setSize:NSMakeSize(128, 128)];
[artworkMenuItem setImage:songArtwork];
[Menu insertItem:artworkMenuItem atIndex:0];
I for some songs it works, and displays the artwork nicely in the menu item, but for others I get a SIGABRT on the line:
[songArtwork setSize:NSMakeSize(128, 128)];
The output of the console is as follows:
2011-08-12 23:13:20.094 SongViewer[2146:707] -[NSAppleEventDescriptor setSize:]: unrecognized selector sent to instance 0x102827f70
2011-08-12 23:13:20.095 SongViewer[2146:707] An uncaught exception was raised
2011-08-12 23:13:20.096 SongViewer[2146:707] -[NSAppleEventDescriptor setSize:]: unrecognized selector sent to instance 0x102827f70
2011-08-12 23:13:20.097 SongViewer[2146:707] (
0 CoreFoundation 0x00007fff86f11986 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8b04cd5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff86f9d5ae -[NSObject doesNotRecognizeSelector:] + 190
3 CoreFoundation 0x00007fff86efe803 ___forwarding___ + 371
4 CoreFoundation 0x00007fff86efe618 _CF_forwarding_prep_0 + 232
5 SongViewer 0x0000000100002a83 -[IPMenulet awakeFromNib] + 4483
6 CoreFoundation 0x00007fff86f089e1 -[NSObject performSelector:] + 49
7 CoreFoundation 0x00007fff86f08962 -[NSSet makeObjectsPerformSelector:] + 274
8 AppKit 0x00007fff8d9d9c27 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1245
9 AppKit 0x00007fff8d9d01b9 loadNib + 322
10 AppKit 0x00007fff8d9cf6b6 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 217
11 AppKit 0x00007fff8d9cf5d1 +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 141
12 AppKit 0x00007fff8d9cf514 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 364
13 AppKit 0x00007fff8dc42355 NSApplicationMain + 398
14 SongViewer 0x0000000100001882 main + 34
15 SongViewer 0x0000000100001854 start + 52
)
2011-08-12 23:13:20.098 SongViewer[2146:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSAppleEventDescriptor setSize:]: unrecognized selector sent to instance 0x102827f70'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff86f11986 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8b04cd5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff86f9d5ae -[NSObject doesNotRecognizeSelector:] + 190
3 CoreFoundation 0x00007fff86efe803 ___forwarding___ + 371
4 CoreFoundation 0x00007fff86efe618 _CF_forwarding_prep_0 + 232
5 SongViewer 0x0000000100002a83 -[IPMenulet awakeFromNib] + 4483
6 CoreFoundation 0x00007fff86f089e1 -[NSObject performSelector:] + 49
7 CoreFoundation 0x00007fff86f08962 -[NSSet makeObjectsPerformSelector:] + 274
8 AppKit 0x00007fff8d9d9c27 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1245
9 AppKit 0x00007fff8d9d01b9 loadNib + 322
10 AppKit 0x00007fff8d9cf6b6 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 217
11 AppKit 0x00007fff8d9cf5d1 +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 141
12 AppKit 0x00007fff8d9cf514 +[NSBundle(NSNibLoading) loadNibNamed:owner:] + 364
13 AppKit 0x00007fff8dc42355 NSApplicationMain + 398
14 SongViewer 0x0000000100001882 main + 34
15 SongViewer 0x0000000100001854 start + 52
)
terminate called throwing an exception(gdb)
If anyone has any idea what could be wrong, please let me know!!
Ok so I figured it out. The solution is to use the NSData raw data provided by the API rather than the NSImage. So I used:
NSImage *songArtwork = [[NSImage alloc] initWithData:[artwork rawData]];
rather than
songArtwork = [artwork data];
I have to fetch batch of track artworks from iTunes and use ‘rawData’ too.
But this way is inefficient.
I found a better way (actually it decreases ‘fetch’ time about 2 times, it’s very significant when fetching artworks for many tracks using ‘valueForKey:’ according to «Improving the Performance of Scripting Bridge Code»).
So I decided to understand what’s wrong with iTunesArtwork ‘data’ property.
We expect to get an NSImage object (according to iTunes.h ), but real object is kind of ‘NSAppleEventDescriptor’. And it’s easy to guess, that this object contains an image for us. So we can just use ‘data’ property to get image data. And this is really faster than getting ‘rawData’ from iTunesArtwork.
But sometimes iTunes return NSImage object instead NSAppleEventDescriptor. This is an strange behavior, but it's still faster then using rawData.

Variable is Not A CFString Error

Hey fellas, while running through a debugger I am seeing the following appear the second time it sets the variables (timestamp and checksum are set through this method one after the other, it works fine when no DataFeedManager exists, but upon returning to it again it crashes when it's time to set the checksum):
Here is the function of interest:
//sets specified attribute to the passed in value while ensuring that only one instance of the DataFeedManager exists
-(void)setItemInDFMWhilePreservingEntityUniquenessForItem:(attribute)attr withValue:(id)value {
SJLog(#"CoreDataSingleton.m setItemInDFMWhilePreservingEntityUniquenessForItem");
NSError *error;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:#"DataFeedManager" inManagedObjectContext:[self managedObjectContext]];
[fetchRequest setEntity:entity];
NSUInteger numEntities = [[self managedObjectContext] countForFetchRequest:fetchRequest error:&error];
if (numEntities == NSNotFound) { // ERROR
//...
} else if (numEntities == 0) {
DataFeedManager *dfm = (DataFeedManager *)[NSEntityDescription insertNewObjectForEntityForName:#"DataFeedManager"
inManagedObjectContext:[self managedObjectContext]];
if (attr == checksumAttr) { //BLOCK OF INTEREST
NSString *tempVal = [[NSString alloc] initWithString:value];
[dfm setLastUpdateCheckSum:[NSString stringWithString:tempVal]];
} else if (attr == timeStampAttr) {
[dfm setTimeStamp:value];
}
} else { // more than zero entities
if (numEntities == 1) {
NSArray *fetchedObjects = [[self managedObjectContext] executeFetchRequest:fetchRequest error:&error];
if (attr == checksumAttr) { //BLOCK OF INTEREST
NSString *tempVal = [[NSString alloc] initWithString:value];
[[fetchedObjects objectAtIndex:0] setLastUpdateCheckSum:[NSString stringWithString:tempVal]]; //crashes at this line, after successfully going through the previous BLOCK OF INTEREST area
} else if (attr == timeStampAttr) {
[[fetchedObjects objectAtIndex:0] setTimeStamp:value];
}
} else { // ERROR: more than one entity
//...
}
} // else more than zero entities
[fetchRequest release];
}//setItemInDFMWhilePreservingEntityUniquenessForItem:withValue:
I have marked the areas of interest with //BLOCK OF INTEREST comments and have indicated upon which line the crash occurs (scroll right to see it!). Here is a readout of error from the console:
2011-04-22 17:18:10.924 Parking[26783:207] CoreDataSingleton.m setItemInDFMWhilePreservingEntityUniquenessForItem
2011-04-22 17:18:10.924 Parking[26783:207] -[__NSCFDictionary length]: unrecognized selector sent to instance 0xac34850
2011-04-22 17:18:10.970 Parking[26783:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary length]: unrecognized selector sent to instance 0xac34850'
*** Call stack at first throw:
(
0 CoreFoundation 0x011a0be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x012f55c2 objc_exception_throw + 47
2 CoreFoundation 0x011a26fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x01112366 ___forwarding___ + 966
4 CoreFoundation 0x01111f22 _CF_forwarding_prep_0 + 50
5 Foundation 0x00c4d1e1 -[NSPlaceholderString initWithString:] + 162
6 Foundation 0x00c562c2 +[NSString stringWithString:] + 72
7 Parking 0x0000e4d4 -[CoreDataSingleton setItemInDFMWhilePreservingEntityUniquenessForItem:withValue:] + 774
8 Parking 0x00008bb4 -[DataUpdater allDataRetrievedWithSuccess:withError:] + 225
9 Parking 0x0000952e -[DataUpdater dataDownloadCompleted:forFunc:withData:withError:] + 769
10 Parking 0x00010bb5 -[DataRetriever finish] + 432
11 Parking 0x00010e75 -[DataRetriever connectionDidFinishLoading:] + 36
12 Foundation 0x00c61172 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 108
13 Foundation 0x00c610cb _NSURLConnectionDidFinishLoading + 133
14 CFNetwork 0x0348e606 _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 220
15 CFNetwork 0x03559821 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 293
16 CFNetwork 0x03559b0f _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 1043
17 CFNetwork 0x03484e3c _ZN19URLConnectionClient13processEventsEv + 100
18 CFNetwork 0x03484cb7 _ZN17MultiplexerSource7performEv + 251
19 CoreFoundation 0x0118201f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
20 CoreFoundation 0x010e019d __CFRunLoopDoSources0 + 333
21 CoreFoundation 0x010df786 __CFRunLoopRun + 470
22 CoreFoundation 0x010df240 CFRunLoopRunSpecific + 208
23 CoreFoundation 0x010df161 CFRunLoopRunInMode + 97
24 GraphicsServices 0x01414268 GSEventRunModal + 217
25 GraphicsServices 0x0141432d GSEventRun + 115
26 UIKit 0x0004e42e UIApplicationMain + 1160
27 Parking 0x00002698 main + 102
28 Parking 0x00002629 start + 53
)
terminate called after throwing an instance of 'NSException'
I believe it has something to do with copying the string adequately (can't set a string I don't own to the store). I have tried placing [value copy] as well as &value(saw this sort of thing work for someone else, so I thought I would give it a shot) to no avail. Shouldn't my current method adequately take ownership of the string? I still can't figure out what I am doing wrong. Any help appreciated. Thanks!
Best guess (based in part on this answer) is that you're passing in a released object as the value when you call the method the second time, or possibly that value is of class NSDictionary on your second time through – it's not clear from this code snippet why your method takes an argument of type id and then blithely treats it as an instance of NSString, but this may be part of the problem.
Note that your -setItemInDFMWhilePreservingEntityUniquenessForItem:withValue: accepts an arbitrary object in its second argument (type id).
Inside the method, you do:
NSString *tempVal = [[NSString alloc] initWithString:value];
Unless value is an Objective-C string, this will crash your program. In fact, your crash log shows that in that particular execution value was an NSDictionary. You need to make sure that value is an NSString.
Also, note that you own the string you’re assigning to tempVal since you’ve used +alloc. Don’t forget to release that string.

core data strange unrecognized selector sent to instance

Dear community. I try to pickup some data from managed object context in main AppDelegate from other thread.
NSError *error = nil;
AppDelegate *appDelegate = [[NSApplication sharedApplication] delegate];
NSFetchRequest *requestCodesList = [[[NSFetchRequest alloc] init] autorelease];
[requestCodesList setEntity:[NSEntityDescription entityForName:#"CodesvsDestinationsList"
inManagedObjectContext:[appDelegate managedObjectContext]]];
[requestCodesList setPredicate:[NSPredicate predicateWithFormat:#"(%K.carrier.name == %#) AND (%K.prefix == %#) AND (code == %#) AND (originalCode == %#)",
destinationTypeRelationShipName,
carrierName,
destinationTypeRelationShipName,
prefix,
[destinationParameters valueForKey:#"code"],
[destinationParameters valueForKey:#"originalCode"]]];
//[destinationParameters valueForKey:#"originalCode"]]];
NSLog(#" Predicate is:%# START",requestCodesList);
NSArray *codesInLocalSystem = [[appDelegate managedObjectContext] executeFetchRequest:requestCodesList error:&error];
I just read information from main MOC, so, it's can't be a thread-safe trouble, bcs i don't write nothing there. The problem is start just sometime. Here is what i receive as error:
2010-12-16 12:55:05.162 snow[53293:3a0b] -[NSManagedObject isTemporaryID]: unrecognized selector sent to instance 0x11836db00
*** Call stack at first throw:
(
0 CoreFoundation 0x00007fff84cb47b4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00007fff87ec40f3 objc_exception_throw + 45
2 CoreFoundation 0x00007fff84d0e110 +[NSObject(NSObject) doesNotRecognizeSelector:] + 0
3 CoreFoundation 0x00007fff84c8691f ___forwarding___ + 751
4 CoreFoundation 0x00007fff84c82a68 _CF_forwarding_prep_0 + 232
5 CoreData 0x00007fff85374341 getValueCore + 33
6 CoreData 0x00007fff853742e4 _PFCMT_GetValue + 20
7 CoreData 0x00007fff8537422d -[NSManagedObjectContext(_NSInternalAdditions) _retainedObjectWithID:optionalHandler:withInlineStorage:] + 45
8 CoreData 0x00007fff85376edd _PF_FulfillDeferredFault + 541
9 CoreData 0x00007fff8537aab7 _sharedIMPL_pvfk_core + 87
10 CoreData 0x00007fff8537ac28 -[NSManagedObject(_PFDynamicAccessorsAndPropertySupport) _genericValueForKey:withIndex:flags:] + 40
11 CoreData 0x00007fff853804be -[NSManagedObject valueForKey:] + 270
12 Foundation 0x00007fff854b9f6f -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 357
13 Foundation 0x00007fff854b9f82 -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 376
14 Foundation 0x00007fff8551ca22 -[NSFunctionExpression expressionValueWithObject:context:] + 530
15 Foundation 0x00007fff854e03a7 -[NSComparisonPredicate evaluateWithObject:substitutionVariables:] + 223
16 Foundation 0x00007fff8551c7ba -[NSCompoundPredicateOperator evaluatePredicates:withObject:substitutionVariables:] + 235
17 Foundation 0x00007fff8551c690 -[NSCompoundPredicate evaluateWithObject:substitutionVariables:] + 265
18 CoreData 0x00007fff85364e41 -[NSManagedObjectContext executeFetchRequest:error:] + 1361
19 snow 0x0000000100014a5e -[AppController externalDestinationsForCodeIsAlresdyInLocalDatabaseForCarrierName:withEnabledState:withDestinationParameters:withDestinationTypeRelationShipName:withPrefix:withExternalRateNumber:withAddedDestinations:withCheckForLocalAddedDestinations:] + 862
20 snow 0x00000001000158aa -[AppController updateDestinationListforCarrier:destinationType:] + 2586
21 snow 0x0000000100015d72 -[AppController makeUpdatesForCarrier:andTypeOfOperation:forDirection:] + 754
22 snow 0x00000001000160a1 -[AppController main] + 689
23 Foundation 0x00007fff854d3de4 -[__NSOperationInternal start] + 681
24 Foundation 0x00007fff855b2beb __doStart2 + 97
25 libSystem.B.dylib 0x00007fff84f452c4 _dispatch_call_block_and_release + 15
26 libSystem.B.dylib 0x00007fff84f23831 _dispatch_worker_thread2 + 239
27 libSystem.B.dylib 0x00007fff84f23168 _pthread_wqthread + 353
28 libSystem.B.dylib 0x00007fff84f23005 start_wqthread + 13
)
terminate called after throwing an instance of 'NSException'
For the sake of anybody else running into this - it's likely that you're passing an NSManagedObject subclass to a method that wants an NSManagedObjectID. Check that your method signatures line up between .h and .m files.
It may not be the actual source of your problem; but ManagedObjectContexts are intended to used one per thread. If you want to access Core Data objects you have to use a separate context for each thread and pass IDs between them.
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdConcurrency.html
I got this issue by passing in the wrong ID to existingObjectWithID:error:. I was passing in the object's id when I should have used objectID.