开发者

Core Data save exception NSInvalidArgumentException

开发者 https://www.devze.com 2023-03-07 07:31 出处:网络
This bug is weird since it happens at some points while program is running. After saving the context around thirty times, the program crashes.

This bug is weird since it happens at some points while program is running. After saving the context around thirty times, the program crashes.

Could you help me by pointing out my mistakes? Thanks!

-[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 __CF开发者_如何学PythonRunLoopDoSources0 + 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


from the exception info it looks like you are trying to extract NSString information from an NSNumber. You may want to check out this Q/A for help in troubleshooting: Core Data save exception


Something expects an NSNumber object to be an NSString object. My guess is that the model has an entity with a string attribute, but the subclass of NSManagedObject corresponding to that entity in the model has an NSNumber attribute. Maybe the model was changed, and the associated class definition is out of sync. Maybe it's an optional attribute that is empty for most objects, and then when it's finally used, thirty saves into the running of the app, it triggers this exception.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号