我的应用在保存核心数据时发生崩溃。以下是堆栈:
#0 0x01646725 in _PFObjectIDFastEquals64 ()
#1 0x018aba17 in __CFDictionaryEquateKeys ()
#2 0x018f0967 in ___CFBasicHashFindBucket_Linear ()
#3 0x017fb9ab in CFBasicHashSetValue ()
#4 0x017fb799 in CFDictionarySetValue ()
#5 0x0163cab3 in _PFCMT_SetValue ()
#6 0x01668d68 in -[NSManagedObjectContext(_NSInternalAdditions) _changeIDsForManagedObjects:toIDs:] ()
#7 0x0167aaff in -[NSSQLCore commitChanges:] ()
#8 0x0166e070 in -[NSSQLCore saveChanges:] ()
#9 0x0162c199 in -[NSSQLCore executeRequest:withContext:error:] ()
#10 0x016dc70b in -[NSPersistentStoreCoordinator executeRequest:withContext:error:] ()
#11 0x01664948 in -[NSManagedObjectContext save:] ()
#12 0x000c8ee4 in -[SensorController performDataRecord] (self=0x69633d0, _cmd=0x27eaa4) at SensorController.m:760
#13 0x01d7cefc in -[NSObject(NSThreadPerformAdditions) performSelectornThread:withObject:waitUntilDone:modes:] ()
#14 0x01d8f506 in -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:] ()
#15 0x000c8d60 in -[SensorController recordData] (self=0x69633d0, _cmd=0x27eab6) at SensorController.m:744
#16 0x01d94749 in __NSFireTimer ()
#17 0x018ba8c3 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ ()
#18 0x018bbe74 in __CFRunLoopDoTimer ()
#19 0x018182c9 in __CFRunLoopRun ()
#20 0x01817840 in CFRunLoopRunSpecific ()
#21 0x01817761 in CFRunLoopRunInMode ()
#22 0x027cc1c4 in GSEventRunModal ()
#23 0x027cc289 in GSEventRun ()
#24 0x007b6c93 in UIApplicationMain ()
#25 0x00083801 in main (argc=1, argv=0xbffff60c) at main.m:50
数据被插入到一个线程上,使用一个非主线程上下文。这只会在不常见的情况下发生,但在长时间使用后仍然经常会频繁崩溃。正如您从堆栈中看到的那样,我正在主线程上执行保存,并等待它完成。
另外,作为预防措施,我正在查看保存前的上下文。
最后,将上下文设置为保留对象:
[context setRetainsRegisteredObjects:YES];
任何帮助将不胜感激。
Best Answer-推荐答案 strong>
没什么可继续的,但您应该保存在插入/更新对象的同一线程上。
当商店尝试更改对象 ID 时,似乎发生了崩溃。反过来,这表明您可能有两个或多个实例化对象键控到相同的存储表示。
关于ios - 核心数据 EXC_BAD_ACCESS 随机保存,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/6822839/
|