0
我嘗試調用managedObjectContext上的save方法時出現以下錯誤。管理對象上下文刪除,然後保存對象引發objc_exception_throw錯誤
#0 0x939214e6 in objc_exception_throw
#1 0x01ded83b in -[NSObject doesNotRecognizeSelector:]
#2 0x01d84676 in ___forwarding___
#3 0x01d606c2 in __forwarding_prep_0___
#4 0x01c618b6 in -[NSFetchedResultsController(PrivateMethods) _managedObjectContextDidChange:]
#5 0x0003263a in _nsnote_callback
#6 0x01d4f005 in _CFXNotificationPostNotification
#7 0x0002fef0 in -[NSNotificationCenter postNotificationName:object:userInfo:]
#8 0x01bc217d in -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:]
#9 0x01c21763 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:]
#10 0x01ba65ea in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:]
#11 0x01bdc728 in -[NSManagedObjectContext save:]
我做了一些改動OrderItem的實體來到這個下面的代碼,在這裏我想取消任何插入之前OrderItem的
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; [fetchRequest setEntity:[NSEntityDescription entityForName:@"OrderItem" inManagedObjectContext:managedObjectContext]]; NSArray *deleteItems = [managedObjectContext executeFetchRequest:fetchRequest error:&error]; for (id item in deleteItems) [managedObjectContext deleteObject:item]; if (![managedObjectContext save:&error]){ NSLog(@"deleting OrderItem failed: %@, %@", error, [error userInfo]); return FALSE; }
上線時出現錯誤[managedObjectContext保存:&錯誤]不去NSLog,但引發異常。
我在做什麼錯?有人告訴我如何,請?
如果您有警告,您必須清除這些警告,因爲這些警告之一可能導致您的問題。任何答案都不能以警告作爲可能的問題。 – 2010-02-23 20:26:50
您好Marcus,我還沒有想出如何解決這個錯誤。你對這個問題有一些提示,或者你需要我提供更多信息才能給出答案? – 2010-02-23 21:02:28