I am getting EXC_BAD_INSTRUCTION in NSUrlConnection sendSynchronousRequest - objective-c

Exception generating code:
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSString* serverURL=getServerUrl();
NSData *postData = [NSJSONSerialization dataWithJSONObject:myPostDataNSArray options:0 error:nil];
[request setHTTPMethod:#"POST"];
[request setURL:[NSURL URLWithString: serverURL]];
[request addValue:#"application/json" forHTTPHeaderField: #"Content-Type"];
[request setHTTPBody:postData];
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
Stack trace:
0 libsystem_trace.dylib 0x00007fff7684d8af _os_trace_read_file_at + 417
1 libsystem_trace.dylib 0x00007fff7684d944 _os_trace_read_plist_at + 46
2 libsystem_trace.dylib 0x00007fff7684929b _os_log_preferences_load + 148
3 libsystem_trace.dylib 0x00007fff7684a00a _os_log_preferences_refresh + 110
4 libsystem_trace.dylib 0x00007fff76849bb6 os_log_create + 999
5 libsqlite3.dylib 0x00007fff75e0a834 sqlite3_initialize + 1364
6 libsqlite3.dylib 0x00007fff75e08c02 openDatabase + 114
7 com.apple.CFNetwork 0x00007fff4d5d6fdb -[NSURLCacheDBReader _openDBReadConnections] + 140
8 com.apple.CFNetwork 0x00007fff4d5d6f2b -[NSURLCacheDBReader openAndPrepareReadCacheDB] + 22
9 com.apple.CFNetwork 0x00007fff4d4babd2 __CFURLCache::createNSURLStorageClient(__CFString const*, long, std::__1::shared_ptr<__CFURLCache>) + 166
10 com.apple.CFNetwork 0x00007fff4d5bb052 __CFURLCacheCreateInternal(__CFAllocator const*, long, long, __CFString const*, bool, bool) + 633
11 com.apple.CFNetwork 0x00007fff4d4ba480 -[NSURLCache initWithMemoryCapacity:diskCapacity:diskPath:] + 168
12 com.apple.CFNetwork 0x00007fff4d4ba27b +[NSURLCache sharedURLCache] + 96
13 com.apple.CFNetwork 0x00007fff4d4c7fa8 -[__NSURLSessionLocal _createXURLCache0] + 40
14 com.apple.CFNetwork 0x00007fff4d4c7f34 -[__NSURLSessionLocal _createXURLCache] + 71
15 com.apple.CFNetwork 0x00007fff4d4df282 URLConnectionClient::URLConnectionClient(ClassicURLConnection*, NSURLSessionTask const*, dispatch_queue_s*) + 150
16 com.apple.CFNetwork 0x00007fff4d4df18b URLConnectionClient_Classic::URLConnectionClient_Classic(ClassicURLConnection*, NSURLSessionTask const*, CFURLConnectionClient_V1 const*, dispatch_queue_s*) + 21
17 com.apple.CFNetwork 0x00007fff4d4df02f ClassicURLConnection::initialize(CFURLConnectionClient_V1*, NSURLSessionTask const*) + 145
18 com.apple.CFNetwork 0x00007fff4d4ddecc ClassicURLConnection::initialize(_CFURLRequest const*, _CFURLRequest*, CFURLConnectionClient_V1*, __CFDictionary const*) + 216
19 com.apple.CFNetwork 0x00007fff4d4ddc64 CFURLConnectionCreateWithProperties + 297
20 com.apple.CFNetwork 0x00007fff4d5121cc CFURLConnectionCreate + 52
21 com.apple.CFNetwork 0x00007fff4d5ce4c9 SyncClient::SyncClient(__CFAllocator const*, _CFURLRequest const*, dispatch_queue_s*, void (__CFData const*, _CFURLResponse*, __CFError*) block_pointer) + 213
22 com.apple.CFNetwork 0x00007fff4d5ce1d4 CFURLConnectionSendSynchronousRequest + 326
23 com.apple.CFNetwork 0x00007fff4d5e58a4 +[NSURLConnection sendSynchronousRequest:returningResponse:error:] + 117
Also I can see following info in crash log:
Application Specific Information:
BUG IN CLIENT OF LIBTRACE: don't close random fds
I am new to objective c. Thanks in advance for your valuable time.

It looks like the NSURL shared cache uses SQLite for its on-disk storage. I did not know that. Interesting.
I'm guessing this call is not happening on the main thread. If that's true, then this backtrace raises a number of red flags for me, because SQLite is not thread-safe by default, and I've seen fascinating database corruption and other bugs when one assumes that it is.
I'd try explicitly calling [NSURLCache sharedURLCache] from your main thread before spawning this code, and see if the problem goes away. If not, you probably have a corrupt cache database on disk.

Related

Consume WCF service in xcode 5 and ios 7

I have created a WCF Service to insert data in sql server, so that why I have followed the below structure.
I created first the method and his Implementation;
In WCF interface:
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "json/InsertEmployee/{id1}/{id2}/{id3}")]
bool InsertEmployeeMethod(string id1,string id2, string id3);
In Implementation:
public bool InsertEmployeeMethod(string id1, string id2, string id3)
{
int success = 0;
using (SqlConnection conn = new SqlConnection("Data Source=NXT1;User ID=zakaria;Password=11;Initial Catalog=EmpDB;Integrated Security=false"))
{
conn.Open();
decimal value = Decimal.Parse(id3);
string cmdStr = string.Format("INSERT INTO EmpInfo VALUES('{0}','{1}',{2})", id1, id2, value);
SqlCommand cmd = new SqlCommand(cmdStr, conn);
success = cmd.ExecuteNonQuery();
conn.Close();
}
return (success != 0 ? true : false);
}
to test the web service, try that URL:
"41.142.251.142/JsonWcfService/GetEmployees.svc/json/InsertEmployee/myName/MylastName/6565"
until here all is working well,
So to test this web servcie, I created in my Main.storyboard 3 textFields (firstName.text and lastName.text and salary.text and a button to send the data entered). note that I have worked with xcode 5 and ios 7.
I declared the url inside my viewcontroller.m as following:
myViewController.m:
#define BaseWcfUrl [NSURL URLWithString:#"41.142.251.142/JsonWcfService/GetEmployees.svc/json/InsertEmployee/{id1}/{id2}/{id3}"]
Then I implemented the Insert Employee Method related to click button.
-(void) insertEmployeeMethod
{
if(firstname.text.length && lastname.text.length && salary.text.length)
{
NSString *getValue= [BaseWcfUrl stringByAppendingFormat:#"InsertEmployee/%#/%#/%#",firstname.text,lastname.text,salary.text];
NSURL *WcfServiceURL = [NSURL URLWithString:getValue];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:WcfServiceURL];
[request setHTTPMethod:#"POST"];
// connect to the web
NSData *respData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
// NSString *respStr = [[NSString alloc] initWithData:respData encoding:NSUTF8StringEncoding];
NSError *error;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:respData
options:NSJSONReadingMutableContainers
error:&error];
NSNumber *isSuccessNumber = (NSNumber*)[json objectForKey:#"InsertEmployeeMethodResult"];
}
}
So the issue that I have encountered is that the system always return the str value as "Nil"
NSString *getValue= [BaseWcfUrl stringByAppendingFormat:#"InsertEmployee/%#/%#/%#",firstname.text,lastname.text,salary.text];
so you can see all the message error here :
2014-02-17 19:49:49.419 InsertData[2384:70b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'
* First throw call stack:
0 CoreFoundation 0x017395e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bc8b6 objc_exception_throw + 44
2 CoreFoundation 0x017393bb +[NSException raise:format:] + 139
3 Foundation 0x012037a2 +[NSJSONSerialization JSONObjectWithData:options:error:] + 67
4 InsertData 0x0000236c -[ViewController sendData:] + 1452
5 libobjc.A.dylib 0x014ce874 -[NSObject performSelector:withObject:withObject:] + 77
6 UIKit 0x0022c0c2 -[UIApplication sendAction:to:from:forEvent:] + 108
7 UIKit 0x0022c04e -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
8 UIKit 0x003240c1 -[UIControl sendAction:to:forEvent:] + 66
9 UIKit 0x00324484 -[UIControl _sendActionsForEvents:withEvent:] + 577
10 UIKit 0x00323733 -[UIControl touchesEnded:withEvent:] + 641
11 UIKit 0x0026951d -[UIWindow _sendTouchesForEvent:] + 852
12 UIKit 0x0026a184 -[UIWindow sendEvent:] + 1232
13 UIKit 0x0023de86 -[UIApplication sendEvent:] + 242
14 UIKit 0x0022818f _UIApplicationHandleEventQueue + 11421
CoreFoundation 0x016c283f CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 15
16 CoreFoundation 0x016c21cb __CFRunLoopDoSources0 + 235
17 CoreFoundation 0x016df29e __CFRunLoopRun + 910
18 CoreFoundation 0x016deac3 CFRunLoopRunSpecific + 467
19 CoreFoundation 0x016de8db CFRunLoopRunInMode + 123
20 GraphicsServices 0x036de9e2 GSEventRunModal + 192
21 GraphicsServices 0x036de809 GSEventRun + 104
22 UIKit 0x0022ad3b UIApplicationMain + 1225
23 InsertData 0x00002d5d main + 141
24 libdyld.dylib 0x01d7770d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
can you please help me on that, i'm very stressed with.
much appreciate .
I think you just have the wrong URL, you're adding InsertEmployee twice.
Change BaseWcfUrl to just [NSURL URLWithString:#"41.142.251.142/JsonWcfService/GetEmployees.svc/json/"] instead of [NSURL URLWithString:#"41.142.251.142/JsonWcfService/GetEmployees.svc/json/InsertEmployee/{id1}/{id2}/{id3}"]
To be absolutely sure, log the final URL to the console (or look at it in the debugger) to make sure it's correct.
Also, in your code, in NSURL *WcfServiceURL = [NSURL URLWithString:str];, where is str coming from? Did you mean getValue there?

NSTask in Objective-C

So I'm trying to run some terminal commands from my program, and I am getting some confusing errors.
Im a newer developer coming from Java, so I may be missing something.
Heres the code:
NSTask *task = [[NSTask alloc] init];
NSString *commitText = [commitMessage stringValue];
NSString *a = [NSString stringWithFormat:#"cd %#", dirPath];
NSString *c = [NSString stringWithFormat:#"git commit -m '%#'", commitText];
NSArray *commands = [[NSArray alloc]initWithObjects:a,
#"git add 'Project'",
c,
#"git push origin HEAD",
nil];
[task setLaunchPath:#"/bin/sh"];
// Do commands
NSArray *args = [NSArray arrayWithObjects:commands,
nil];
[task setArguments: args];
[task launch];
And here are the errors:
2012-06-09 08:35:20.561 Auto Git[5433:403] -[__NSArrayI fileSystemRepresentation]: unrecognized selector sent to instance 0x7fb250d6a1e0
2012-06-09 08:35:20.561 Auto Git[5433:403] -[__NSArrayI fileSystemRepresentation]: unrecognized selector sent to instance 0x7fb250d6a1e0
2012-06-09 08:35:20.679 Auto Git[5433:403] (
0 CoreFoundation 0x00007fff870b4f56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff90e35d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff871411be -[NSObject doesNotRecognizeSelector:] + 190
3 CoreFoundation 0x00007fff870a1e23 ___forwarding___ + 371
4 CoreFoundation 0x00007fff870a1c38 _CF_forwarding_prep_0 + 232
5 Foundation 0x00007fff9174f3a3 -[NSConcreteTask launchWithDictionary:] + 901
6 Auto Git 0x000000010d83c6db -[Push push:] + 571
7 CoreFoundation 0x00007fff870a470d -[NSObject performSelector:withObject:] + 61
8 AppKit 0x00007fff8e0f8f7e -[NSApplication sendAction:to:from:] + 139
9 AppKit 0x00007fff8e0f8eb2 -[NSControl sendAction:to:] + 88
10 AppKit 0x00007fff8e0f8ddd -[NSCell _sendActionFrom:] + 137
11 AppKit 0x00007fff8e0f82a0 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2014
12 AppKit 0x00007fff8e177fc4 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 489
13 AppKit 0x00007fff8e0f6eaa -[NSControl mouseDown:] + 786
14 AppKit 0x00007fff8e0c2348 -[NSWindow sendEvent:] + 6306
15 AppKit 0x00007fff8e05ba55 -[NSApplication sendEvent:] + 5593
16 AppKit 0x00007fff8dff20c6 -[NSApplication run] + 555
17 AppKit 0x00007fff8e26e244 NSApplicationMain + 867
18 Auto Git 0x000000010d83bff2 main + 34
19 Auto Git 0x000000010d83bfc4 start + 52
20 ??? 0x0000000000000003 0x0 + 3
)
Thanks!
Your arguments array contains an array. It should be an array of strings. Use your commands object as that parameter for NSTask.
I think the problem is that your passing a array with a array of strings to setArguments. You should pass an array with strings only not an nested array.
But I think you misunderstand how the arguments to NSTask works. You should probably do something like this:
[task setArguments:[[[NSArray alloc] initWithObjects:
#"git", #"add", #"Project", nil]
autorelease]];
Etc, or if you really want to use sh you probably need to add some ; to separate the shell commands.

*** 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.

NSURLRequest throwing runtime error

Trying to create a request only to have a runtime error thrown. Method initiating the request:
- (void)loadMemberData {
//build URL
NSMutableString *url = [[NSMutableString alloc] initWithString:appDelegate.apiURL];
[url appendFormat:#"&subaction=singlestat&memberID=%d", [[NSUserDefaults standardUserDefaults] integerForKey:#"memberID"]];
NSURL *tempURL = [[NSURL alloc] initWithString:url];
NSLog(#"URL: %#", tempURL);
//Create conn
NSURLRequest *request = [[NSURLRequest alloc] requestWithURL:tempURL];
NSLog(#"%#", request);
//conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
//[request release];
}
The URL logs correctly. I have even checked the object type to make sure everything is correct, and all seems good. No compile time errors or warnings. Stack Trace & Log:
[Session started at 2011-03-09 15:02:32 -0500.]
2011-03-09 15:02:33.807 NTR Beer Club[17702:207] URL: https://mydomain.com/path/to/file.php?action=get_app_data&subaction=singlestat&memberID=117
2011-03-09 15:02:33.809 NTR Beer Club[17702:207] -[NSURLRequest requestWithURL:]: unrecognized selector sent to instance 0x4b02cf0
2011-03-09 15:02:33.811 NTR Beer Club[17702:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURLRequest requestWithURL:]: unrecognized selector sent to instance 0x4b02cf0'
*** Call stack at first throw:
(
0 CoreFoundation 0x00db7be9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f0c5c2 objc_exception_throw + 47
2 CoreFoundation 0x00db96fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00d29366 ___forwarding___ + 966
4 CoreFoundation 0x00d28f22 _CF_forwarding_prep_0 + 50
5 NTR Beer Club 0x00002190 -[MyStats loadMemberData] + 358
6 NTR Beer Club 0x000022c8 -[MyStats viewDidLoad] + 215
7 UIKit 0x004b64f0 -[UINib instantiateWithOwner:options:] + 1556
8 UIKit 0x004b8081 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x002c2943 -[UIApplication _loadMainNibFile] + 172
10 UIKit 0x002c34ca -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
11 UIKit 0x002cddb2 -[UIApplication handleEvent:withNewEvent:] + 1533
12 UIKit 0x002c6202 -[UIApplication sendEvent:] + 71
13 UIKit 0x002cb732 _UIApplicationHandleEvent + 7576
14 GraphicsServices 0x016eda36 PurpleEventCallback + 1550
15 CoreFoundation 0x00d99064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16 CoreFoundation 0x00cf96f7 __CFRunLoopDoSource1 + 215
17 CoreFoundation 0x00cf6983 __CFRunLoopRun + 979
18 CoreFoundation 0x00cf6240 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x00cf6161 CFRunLoopRunInMode + 97
20 UIKit 0x002c2fa8 -[UIApplication _run] + 636
21 UIKit 0x002cf42e UIApplicationMain + 1160
22 NTR Beer Club 0x00001b98 main + 102
23 NTR Beer Club 0x00001b29 start + 53
24 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
You should be doing
NSURLRequest *request = [NSURLRequest requestWithURL:tempURL];
The requestWithURL: creates NSURLRequest objects that are autorelease-d.
The actual error message says "unrecognized selector" because requestWithURL: is a class method, but you are using it like an instance method.

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.