请解释一下下面的坠机情况。
#3. NSManagedObjectContext 0x1701c9ab0: xxxxxxxxxx 0 libsystem_kernel.dylib 0x1848898e8 __ulock_wait +8 1 libdispatch.dylib 0x18475977c _dispatch_ulock_wait + 48 2 libdispatch.dylib 0x1847598a4 _dispatch_thread_event_wait_slow + 36 3 libdispatch.dylib 0x1847574f0 _dispatch_barrier_sync_f_slow + 236 4 CoreData 0x187c0703c _perform + 232 5 CoreData0x187c178b8 -NSManagedObjectContext(_NestedContextSupport) executeRequest: CoreData :error:+ 176 6 CoreData 0x187b675e0 -NSManagedObjectContext executeFetchRequest:错误:+ 580 7 MyApp 0x1002f596c专用静态RecentItemsController.cleanupItems(inContext:ofType:limitingTo:sortingByAttribute:withPredicate:) (xxxxx.swift:182) 8 MyApp 0x1002f6574静态xxx.xxx中的专用闭包#1 (inStore:completion:) (xxx.swift:163) 9 MyApp0x1002f5118在静态中部分申请关闭#1 (inStore:completion:) (xxx.swift) 10 CoreData 0x187c0c214 _dispatch_client_callout + 152 11 libdispatch.dylib 0x1847469a0 _dispatch_client_callout+ 16 12 libdispatch.dylib 0x184754ad4 _dispatch_queue_serial_drain + 928 13 libdispatch.dylib 0x474a2cc _dispatch_queue_invoke + 884 14 libdispatch.dylib 0x184754fa8 _dispatch_queue_override_invoke + 344 15 libdispatch.dylib 0x184756a50 _dispatch_root_queue_drain + 540 16 libdispatch.dylib 0x1847567d0 _dispatch_worker_thread3 + 124 17 libsystem_pthread.dylib 0x18494f100 _pthread_wqthread + 1096 18 libsystem_pthread.dylib 0x18494ecac start_wqthread +4
发布于 2017-10-14 06:02:06
查看堆栈跟踪和cleanupItems函数中的代码,我相信问题在于强制展开代码:
let itemsToDelete = try context.fetch(request) as! [R]编写防崩溃代码的第一件事如下
if let itemsToDelete = try context.fetch(request) as? [R] {
itemsToDelete.forEach(context.delete(_:))
log("Deleted \(itemsToDelete.count) \(type) item(s)")
}如果成功的话请告诉我。
https://stackoverflow.com/questions/46321791
复制相似问题