2011-05-19 36 views
1

这个错误是奇怪的,因为它发生在程序运行时的某些点。将上下文保存三十次后,程序崩溃。核心数据保存异常NSInvalidArgumentException

你能通过指出我的错误来帮助我吗?谢谢!

 
-[NSCFNumber UTF8String]: unrecognized selector sent to instance 0x5a627f0 
2011-05-19 17:17:38.650 DMC to Go[16892:40b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFNumber UTF8String]: unrecognized selector sent to instance 0x5a627f0' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x015d95a9 __exceptionPreprocess + 185 
    1 libobjc.A.dylib      0x0172d313 objc_exception_throw + 44 
    2 CoreFoundation      0x015db0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 
    3 CoreFoundation      0x0154a966 ___forwarding___ + 966 
    4 CoreFoundation      0x0154a522 _CF_forwarding_prep_0 + 50 
    5 CoreData       0x002f970f -[NSSQLiteConnection execute] + 1231 
    6 CoreData       0x0034bebd -[NSSQLiteConnection updateRow:] + 365 
    7 CoreData       0x0034ae64 -[NSSQLConnection performAdapterOperations:] + 180 
    8 CoreData       0x0034ab0e -[NSSQLCore _performChangesWithAdapterOps:] + 494 
    9 CoreData       0x003495ea -[NSSQLCore performChanges] + 410 
    10 CoreData       0x00343038 -[NSSQLCore saveChanges:] + 216 
    11 CoreData       0x00301199 -[NSSQLCore executeRequest:withContext:error:] + 409 
    12 CoreData       0x003b170b -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 3691 
    13 CoreData       0x00339948 -[NSManagedObjectContext save:] + 712 
    14 DMC to Go       0x00002f9b -[dmcIpadAppDelegate saveManagedObjectChanges] + 107 
    15 DMC to Go       0x00020c25 +[DmcIpadAppDelegate saveManagedObjectChanges] + 117 
    16 DMC to Go       0x000276e3 -[DownloadFileService observeValueForKeyPath:ofObject:change:context:] + 867 
    17 Foundation       0x00faf1e4 NSKeyValueNotifyObserver + 361 
    18 Foundation       0x00faeca6 NSKeyValueDidChange + 384 
    19 Foundation       0x00f953e2 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 123 
    20 DMC to Go       0x0002c4d4 -[DownloadManager connectionDidFinishLoading:] + 836 
    21 Foundation       0x00fd5112 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 108 
    22 Foundation       0x00fd506b _NSURLConnectionDidFinishLoading + 133 
    23 CFNetwork       0x01dda48e _ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE + 220 
    24 CFNetwork       0x01ea56e1 _ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl + 293 
    25 CFNetwork       0x01dd0c80 _ZN19URLConnectionClient13processEventsEv + 100 
    26 CFNetwork       0x01dd0acf _ZN17MultiplexerSource7performEv + 251 
    27 CoreFoundation      0x015ba8ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 
    28 CoreFoundation      0x0151888b __CFRunLoopDoSources0 + 571 
    29 CoreFoundation      0x01517d86 __CFRunLoopRun + 470 
    30 CoreFoundation      0x01517840 CFRunLoopRunSpecific + 208 
    31 CoreFoundation      0x01517761 CFRunLoopRunInMode + 97 
    32 GraphicsServices     0x0202b1c4 GSEventRunModal + 217 
    33 GraphicsServices     0x0202b289 GSEventRun + 115 
    34 UIKit        0x00839c93 UIApplicationMain + 1160 
    35 DMC to Go       0x00001db9 main + 121 
    36 DMC to Go       0x00001d35 start + 53 
    37 ???         0x00000001 0x0 + 1 
) 
terminate called after throwing an instance of 'NSException' 
Current language: auto; currently objective-c 
kill 
quit 

回答

1

有些东西希望NSNumber对象是NSString对象。我的猜测是该模型有一个带有字符串属性的实体,但与该模型中该实体相对应的NSManagedObject的子类具有NSNumber属性。也许该模型已更改,并且关联的类定义不同步。也许这是一个对大多数对象来说是空的可选属性,然后当它最终被使用时,有三十个保存到应用程序的运行中,它会触发这个异常。