为什么我的iOS应用程序在将模型对象保存到managedObjectContext

时间:2015-07-03 11:07:13

标签: ios objective-c core-data crash encoder

我在数据库中添加模型对象时遇到此崩溃,我已将崩溃标记为

这是崩溃的堆栈跟踪

SIGSEGV SEGV_MAPERR

libobjc.A.dylib 0x366746ba objc_retain + 8 1
基础0x2907887d _encodeObject + 1066 2
基金会0x29079a6f - [NSKeyedArchiver _encodeArrayOfObjects:forKey:] + 400 3
基金会0x2907a051 - [NSArray(NSArray)encodeWithCoder:] + 182 4
基础0x2907887d _encodeObject + 1066 5
MyApp 0x000d3da3 - [WorkOrder encodeWithCoder:](WorkOrder.m:97) 6
基础0x2907887d _encodeObject + 1066 7
基础0x2907ebd9 + [NSKeyedArchiver archivedDataWithRootObject:] + 154 8
CoreData 0x2809c861 - [NSSQLiteConnection执行] + 1762 9
CoreData 0x280d99af - [NSSQLiteConnection updateRow:] + 544 10个
CoreFoundation 0x283a8965 ____NSDictionaryEnumerate_block_invoke421 + 22 11个
CoreFoundation 0x282b8740 CFBasicHashApply + 118 12个
CoreFoundation 0x283a6367 __NSDictionaryEnumerate + 268 13个
CoreData 0x2816bdf3 - [NSSQLCore writeChanges] + 544 14个
CoreData 0x280d493d - [NSSQLCore saveChanges:] + 854 15个
CoreData 0x280a2b25 - [NSSQLCore executeRequest:withContext:error:] + 734 16个
CoreData 0x28154a35 __65- [NSPersistentStoreCoordinator executeRequest:withContext:error:] _ block_invoke + 3622 17个
CoreData 0x2815ca13 gutsOfBlockToNSPersistentStoreCoordinatorPerform + 260 18个
libdispatch.dylib 0x36bc52cf _dispatch_client_callout + 20 19个
libdispatch.dylib 0x36bcca3d _dispatch_barrier_sync_f_invoke + 46 20个
CoreData 0x2814ef8d _perform + 134 21个
CoreData 0x280a2703 - [NSPersistentStoreCoordinator executeRequest:withContext:error:] + 312 22个
CoreData 0x280c47d1 - [NSManagedObjectContext save:] + 854 23个
MyApp 0x0011f83f __37- [WorkOrderManagement saveWorkOrder:] _ block_invoke(WorkOrderManagement.m:96) 24个
libdispatch.dylib 0x36bc52e3 _dispatch_call_block_and_release + 8 25个
libdispatch.dylib 0x36bcf381 _dispatch_root_queue_drain + 1386 26个
libdispatch.dylib 0x36bd03c3 _dispatch_worker_thread3 + 92 27个
libsystem_pthread.dylib 0x36d2cdc1 _pthread_wqthread + 666 28个
libsystem_pthread.dylib 0x36d2cb14 start_wqthread + 6

这是我的代码。 在符号化后发现可疑的崩溃线在此代码块中是为了  [编码器编码对象:self.lstSelectedEmployees forKey:@" lstSelectedEmployees"];

任何帮助都将受到高度赞赏。

-(void) encodeWithCoder:(NSCoder *)coder {
        [coder encodeObject:self.workOrderID forKey:@"workOrderID"];
        [coder encodeObject:self.projectID forKey:@"projectID"];
        [coder encodeObject:self.locationID forKey:@"locationID"];
        [coder encodeObject:self.service forKey:@"service"];
        [coder encodeObject:self.suggestedQty forKey:@"suggestedQty"];
        [coder encodeObject:self.note forKey:@"note"];
        [coder encodeInt:self.appDuration forKey:@"appDuration"];
        [coder encodeObject:self.forDate forKey:@"forDate"];
        [coder encodeObject:self.quantity forKey:@"quantity"];
        [coder encodeObject:self.lstPictures forKey:@"lstPictures"];
        [coder encodeObject:self.lstAudios forKey:@"lstAudios"];
        [coder encodeObject:self.startTime forKey:@"startTime"];
        [coder encodeObject:self.endTime forKey:@"endTime"];
        [coder encodeObject:self.comments forKey:@"comments"];
        [coder encodeObject:self.assignedToEmployeeName forKey:@"assignedToEmployeeName"];
        [coder encodeBool:self.isDone forKey:@"isDone"];
        [coder encodeBool:self.isPartial forKey:@"isPartial"];
        [coder encodeObject:self.lstSelectedEmployees forKey:@"lstSelectedEmployees"];
        [coder encodeObject:self.lstSelectedEquipment forKey:@"lstSelectedEquipment"];
        [coder encodeObject:self.lstSelectedMaterials forKey:@"lstSelectedMaterials"];
        [coder encodeObject:self.selectedVehicle forKey:@"selectedVehicle"];
        [coder encodeInt:self.qtySelectedIndex forKey:@"qtySelectedIndex"];
        [coder encodeInteger:self.elapsedCount forKey:@"elapsedCount"];
        [coder encodeBool:self.counterRunning forKey:@"counterRunning"];
        [coder encodeObject:self.lstEmployees forKey:@"lstEmployees"];
        [coder encodeObject:self.lstEquipment forKey:@"lstEquipment"];
        [coder encodeObject:self.lstChecklist forKey:@"lstChecklist"];
        [coder encodeBool:self.locationChecklistAdded forKey:@"locationChecklistAdded"];
        [coder encodeObject:self.scaleValue forKey:@"scaleValue"];
        [coder encodeObject:self.lstChecklistitems forKey:@"lstChecklistitems"];
 }

1 个答案:

答案 0 :(得分:0)

在崩溃之前要编码的最后一个对象是NSArray,确保该数组中的对象是允许的属性列表类型