2011-05-19 82 views
1

我用managedObjectContext得到了一個很奇怪的問題:保存。在我第一次保存上下文時沒有發生,它只發生在我的程序的某個時刻。你能幫我知道爲什麼發生了,我應該在哪裏找到我的代碼中的錯誤?謝謝。核心數據保存異常

這裏是日誌:

 
-[NSCFNumber UTF8String]: unrecognized selector sent to instance 0x5a64110 
2011-05-19 16:02:43.235 DMC to Go[98212:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber UTF8String]: unrecognized selector sent to instance 0x5a64110' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x015d85a9 __exceptionPreprocess + 185 
    1 libobjc.A.dylib      0x0172c313 objc_exception_throw + 44 
    2 CoreFoundation      0x015da0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 
    3 CoreFoundation      0x01549966 ___forwarding___ + 966 
    4 CoreFoundation      0x01549522 _CF_forwarding_prep_0 + 50 
    5 CoreData       0x002f870f -[NSSQLiteConnection execute] + 1231 
    6 CoreData       0x0034aebd -[NSSQLiteConnection updateRow:] + 365 
    7 CoreData       0x00349e64 -[NSSQLConnection performAdapterOperations:] + 180 
    8 CoreData       0x00349b0e -[NSSQLCore _performChangesWithAdapterOps:] + 494 
    9 CoreData       0x003485ea -[NSSQLCore performChanges] + 410 
    10 CoreData       0x00342038 -[NSSQLCore saveChanges:] + 216 
    11 CoreData       0x00300199 -[NSSQLCore executeRequest:withContext:error:] + 409 
    12 CoreData       0x003b070b -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 3691 
    13 CoreData       0x00338948 -[NSManagedObjectContext save:] + 712 
    14 DMC to Go       0x0000313b -[dmcIpadAppDelegate saveManagedObjectChanges] + 107 
    15 DMC to Go       0x00020dc5 +[DmcIpadAppDelegate saveManagedObjectChanges] + 117 
    16 DMC to Go       0x00027883 -[DownloadFileService observeValueForKeyPath:ofObject:change:context:] + 867 
    17 Foundation       0x00fae1e4 NSKeyValueNotifyObserver + 361 
    18 Foundation       0x00fadca6 NSKeyValueDidChange + 384 
    19 Foundation       0x00f943e2 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 123 
    20 DMC to Go       0x0002c674 -[DownloadManager connectionDidFinishLoading:] + 836 
    21 Foundation       0x00fd4112 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 108 
    22 Foundation       0x00fd406b _NSURLConnectionDidFinishLoading + 133 
    23 CFNetwork       0x01dd948e _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 220 
    24 CFNetwork       0x01ea46e1 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 293 
    25 CFNetwork       0x01dcfc80 _ZN19URLConnectionClient13processEventsEv + 100 
    26 CFNetwork       0x01dcfacf _ZN17MultiplexerSource7performEv + 251 
    27 CoreFoundation      0x015b98ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 
    28 CoreFoundation      0x0151788b __CFRunLoopDoSources0 + 571 
    29 CoreFoundation      0x01516d86 __CFRunLoopRun + 470 
    30 CoreFoundation      0x01516840 CFRunLoopRunSpecific + 208 
    31 CoreFoundation      0x01516761 CFRunLoopRunInMode + 97 
    32 GraphicsServices     0x0202a1c4 GSEventRunModal + 217 
    33 GraphicsServices     0x0202a289 GSEventRun + 115 
    34 UIKit        0x00838c93 UIApplicationMain + 1160 
    35 DMC to Go       0x00001f59 main + 121 
    36 DMC to Go       0x00001ed5 start + 53 
    37 ???         0x00000001 0x0 + 1 
) 
terminate called after throwing an instance of 'NSException' 

當前語言:汽車;目前Objective-C的

+0

您是否正在創建基於管理對象的HTTP響應?是否有可能你期望字符串,但不知何故結束了數字? – TheBlack 2011-05-19 21:22:34

回答

1
  1. 請確保您有任何警告
  2. 認沽斷點在你的代碼,你以爲你是你的對象
  3. 和/或的NSLog%上設置的NSString @之類的NSString的性質你的核心數據對象,並確保它是NSString的一些變體。 (NSLog(@"%@", [obj.property class]);

正在發生的事情是,你要保存在一個地方的NSString一個NSNumber對象的東西。由於NSNumber不響應UTF8String,因此您的應用程序崩潰。

+0

感謝您的回答!讓我試試看,並讓你知道結果。 – NoMads 2011-05-20 16:11:28