未解决的错误 Error Domain=NSCocoaErrorDomain Code=132001 "(null)"
Posted
技术标签:
【中文标题】未解决的错误 Error Domain=NSCocoaErrorDomain Code=132001 "(null)"【英文标题】:Unresolved error Error Domain=NSCocoaErrorDomain Code=132001 "(null)" 【发布时间】:2019-09-23 02:50:08 【问题描述】:当我升级到 ios 13 时,我的应用程序中的很多东西似乎都坏了。其中之一是我的数据是如何保存的。当我点击保存按钮时,我得到了这个未解决的错误:
Unresolved error Error Domain=NSCocoaErrorDomain Code=132001 "(null)" UserInfo=message=attempt to recursively call -save: on the context aborted, stack trace=(
0 CoreData 0x00007fff23759236 -[NSManagedObjectContext save:] + 170
1 owed 0x000000010f86f76a $s4owed13CoreDataStackC11saveContextyyF + 186
2 owed 0x000000010f8d8347 $s4owed14ViewControllerC05tableB0_12cellForRowAtSo07UITableB4CellCSo0iB0C_10Foundation9IndexPathVtF + 10215
3 owed 0x000000010f8d8cb5 $s4owed14ViewControllerC05tableB0_12cellForRowAtSo07UITableB4CellCSo0iB0C_10Foundation9IndexPathVtFTo + 165
4 UIKitCore 0x00007fff47360e4b -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 787
5 UIKitCore 0x00007fff47361364 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 73
6 UIKitCore 0x00007fff4738ea9c -[_UITableViewUpdateSupport(Private) _setupAnimationsForNewlyInsertedCells] + 7750
7 UIKitCore 0x00007fff4739805f -[_UITableViewUpdateSupport _setupAnimations] + 118
8 UIKitCore 0x00007fff4732efb0 -[UITableView _updateWithItems:updateSupport:] + 2883
9 UIKitCore 0x00007fff47326f5f -[UITableView _endCellAnimationsWithContext:] + 17188
10 UIKitCore 0x00007fff47340d22 -[UITableView endUpdatesWithContext:] + 112
11 owed 0x000000010f8db9fb $s4owed14ViewControllerC26controllerDidChangeContentyySo016NSFetchedResultsC0CySo20NSFetchRequestResult_pGF + 267
12 owed 0x000000010f8dba64 $s4owed14ViewControllerC26controllerDidChangeContentyySo016NSFetchedResultsC0CySo20NSFetchRequestResult_pGFTo + 68
13 CoreData 0x00007fff238e00be __82-[NSFetchedResultsController(PrivateMethods) _core_managedObjectContextDidChange:]_block_invoke + 7591
14 CoreData 0x00007fff2376ebfb developerSubmittedBlockToNSManagedObjectContextPerform + 154
15 CoreData 0x00007fff2376eae2 -[NSManagedObjectContext performBlockAndWait:] + 197
16 CoreData 0x00007fff238de305 -[NSFetchedResultsController(PrivateMethods) _core_managedObjectContextDidChange:] + 105
17 CoreFoundation 0x00007fff23ac2c1c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
18 CoreFoundation 0x00007fff23ac20a5 _CFXRegistrationPost1 + 421
19 CoreFoundation 0x00007fff23ac1e0f ___CFXNotificationPost_block_invoke + 175
20 CoreFoundation 0x00007fff23bbffe3 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1811
21 CoreFoundation 0x00007fff23ac1776 _CFXNotificationPost + 950
22 Foundation 0x00007fff2564d429 -[NSNotificationCenter postNotificationName:object:userInfo:] + 59
23 CoreData 0x00007fff2375b4fe -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 541
24 CoreData 0x00007fff237feb3a -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:deletions:updates:refreshes:deferrals:wasMerge:] + 1557
25 CoreData 0x00007fff23755ff3 -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 1217
26 CoreData 0x00007fff237592fb -[NSManagedObjectContext save:] + 367
27 owed 0x000000010f86f76a $s4owed13CoreDataStackC11saveContextyyF + 186
28 owed 0x000000010f955d53 $s4owed23AddPersonViewControllerC8saveNameyyypF + 11699
29 owed 0x000000010f956360 $s4owed23AddPersonViewControllerC8saveNameyyypFTo + 80
30 UIKitCore 0x00007fff47163d19 -[UIApplication sendAction:to:from:forEvent:] + 83
31 UIKitCore 0x00007fff46b55599 -[UIControl sendAction:to:forEvent:] + 223
32 UIKitCore 0x00007fff46b558e3 -[UIControl _sendActionsForEvents:withEvent:] + 398
33 UIKitCore 0x00007fff46b54842 -[UIControl touchesEnded:withEvent:] + 481
34 UIKitCore 0x00007fff4719e21f -[UIWindow _sendTouchesForEvent:] + 2604
35 UIKitCore 0x00007fff4719fb26 -[UIWindow sendEvent:] + 4596
36 UIKitCore 0x00007fff4717b1a7 -[UIApplication sendEvent:] + 356
37 UIKitCore 0x00007fff471faa18 __dispatchPreprocessedEventFromEventQueue + 6847
38 UIKitCore 0x00007fff471fd4de __handleEventQueueInternal + 5980
39 CoreFoundation 0x00007fff23afbac1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
40 CoreFoundation 0x00007fff23afb9ec __CFRunLoopDoSource0 + 76
41 CoreFoundation 0x00007fff23afb1c4 __CFRunLoopDoSources0 + 180
42 CoreFoundation 0x00007fff23af5ecf __CFRunLoopRun + 1263
43 CoreFoundation 0x00007fff23af56b6 CFRunLoopRunSpecific + 438
44 GraphicsServices 0x00007fff3815cbb0 GSEventRunModal + 65
45 UIKitCore 0x00007fff47162a67 UIApplicationMain + 1621
46 owed 0x000000010f8fe4db main + 75
47 libdyld.dylib 0x00007fff5123bcf5 start + 1
), ["stack trace": <_NSCallStackArray 0x600000e5d560>(
0 CoreData 0x00007fff23759236 -[NSManagedObjectContext save:] + 170,
1 owed 0x000000010f86f76a $s4owed13CoreDataStackC11saveContextyyF + 186,
2 owed 0x000000010f8d8347 $s4owed14ViewControllerC05tableB0_12cellForRowAtSo07UITableB4CellCSo0iB0C_10Foundation9IndexPathVtF + 10215,
3 owed 0x000000010f8d8cb5 $s4owed14ViewControllerC05tableB0_12cellForRowAtSo07UITableB4CellCSo0iB0C_10Foundation9IndexPathVtFTo + 165,
4 UIKitCore 0x00007fff47360e4b -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 787,
5 UIKitCore 0x00007fff47361364 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 73,
6 UIKitCore 0x00007fff4738ea9c -[_UITableViewUpdateSupport(Private) _setupAnimationsForNewlyInsertedCells] + 7750,
7 UIKitCore 0x00007fff4739805f -[_UITableViewUpdateSupport _setupAnimations] + 118,
8 UIKitCore 0x00007fff4732efb0 -[UITableView _updateWithItems:updateSupport:] + 2883,
9 UIKitCore 0x00007fff47326f5f -[UITableView _endCellAnimationsWithContext:] + 17188,
10 UIKitCore 0x00007fff47340d22 -[UITableView endUpdatesWithContext:] + 112,
11 owed 0x000000010f8db9fb $s4owed14ViewControllerC26controllerDidChangeContentyySo016NSFetchedResultsC0CySo20NSFetchRequestResult_pGF + 267,
12 owed 0x000000010f8dba64 $s4owed14ViewControllerC26controllerDidChangeContentyySo016NSFetchedResultsC0CySo20NSFetchRequestResult_pGFTo + 68,
13 CoreData 0x00007fff238e00be __82-[NSFetchedResultsController(PrivateMethods) _core_managedObjectContextDidChange:]_block_invoke + 7591,
14 CoreData 0x00007fff2376ebfb developerSubmittedBlockToNSManagedObjectContextPerform + 154,
15 CoreData 0x00007fff2376eae2 -[NSManagedObjectContext performBlockAndWait:] + 197,
16 CoreData 0x00007fff238de305 -[NSFetchedResultsController(PrivateMethods) _core_managedObjectContextDidChange:] + 105,
17 CoreFoundation 0x00007fff23ac2c1c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12,
18 CoreFoundation 0x00007fff23ac20a5 _CFXRegistrationPost1 + 421,
19 CoreFoundation 0x00007fff23ac1e0f ___CFXNotificationPost_block_invoke + 175,
20 CoreFoundation 0x00007fff23bbffe3 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1811,
21 CoreFoundation 0x00007fff23ac1776 _CFXNotificationPost + 950,
22 Foundation 0x00007fff2564d429 -[NSNotificationCenter postNotificationName:object:userInfo:] + 59,
23 CoreData 0x00007fff2375b4fe -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 541,
24 CoreData 0x00007fff237feb3a -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:deletions:updates:refreshes:deferrals:wasMerge:] + 1557,
25 CoreData 0x00007fff23755ff3 -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 1217,
26 CoreData 0x00007fff237592fb -[NSManagedObjectContext save:] + 367,
27 owed 0x000000010f86f76a $s4owed13CoreDataStackC11saveContextyyF + 186,
28 owed 0x000000010f955d53 $s4owed23AddPersonViewControllerC8saveNameyyypF + 11699,
29 owed 0x000000010f956360 $s4owed23AddPersonViewControllerC8saveNameyyypFTo + 80,
30 UIKitCore 0x00007fff47163d19 -[UIApplication sendAction:to:from:forEvent:] + 83,
31 UIKitCore 0x00007fff46b55599 -[UIControl sendAction:to:forEvent:] + 223,
32 UIKitCore 0x00007fff46b558e3 -[UIControl _sendActionsForEvents:withEvent:] + 398,
33 UIKitCore 0x00007fff46b54842 -[UIControl touchesEnded:withEvent:] + 481,
34 UIKitCore 0x00007fff4719e21f -[UIWindow _sendTouchesForEvent:] + 2604,
35 UIKitCore 0x00007fff4719fb26 -[UIWindow sendEvent:] + 4596,
36 UIKitCore 0x00007fff4717b1a7 -[UIApplication sendEvent:] + 356,
37 UIKitCore 0x00007fff471faa18 __dispatchPreprocessedEventFromEventQueue + 6847,
38 UIKitCore 0x00007fff471fd4de __handleEventQueueInternal + 5980,
39 CoreFoundation 0x00007fff23afbac1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17,
40 CoreFoundation 0x00007fff23afb9ec __CFRunLoopDoSource0 + 76,
41 CoreFoundation 0x00007fff23afb1c4 __CFRunLoopDoSources0 + 180,
42 CoreFoundation 0x00007fff23af5ecf __CFRunLoopRun + 1263,
43 CoreFoundation 0x00007fff23af56b6 CFRunLoopRunSpecific + 438,
44 GraphicsServices 0x00007fff3815cbb0 GSEventRunModal + 65,
45 UIKitCore 0x00007fff47162a67 UIApplicationMain + 1621,
46 owed 0x000000010f8fe4db main + 75,
47 libdyld.dylib 0x00007fff5123bcf5 start + 1
)
, "message": attempt to recursively call -save: on the context aborted]
这是保存功能:
/* =====================================
Save Function
======================================*/
@IBAction func saveName(_ sender: Any)
/* STEP 1 - Check to see if there is a person name in the input field */
guard name.text! != "", name.text! != "Add Name" else
// call the warning function
warningText = "You forgot to add a name."
warningMessage()
return
/* STEP 2 - Check to see if that persons names was already used */
let personFetchRequest: NSFetchRequest<Person> = Person.fetchRequest()
personFetchRequest.predicate = NSPredicate(format: "name == %@", name.text!)
print(name.text!)
do
let results = try coreDataStack.managedContext.fetch(personFetchRequest)
print("\(results.count) this is the results count for the predicate")
guard results.count == 0 else
// print("The Same Name is Used")
warningText = "You already used that name."
warningMessage()
return
/* STEP 3 - Use the name that was typed in */
let person = Person(entity: Person.entity(), insertInto: coreDataStack.managedContext)
let trimmedName = name.text!.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
person.name = trimmedName
if(email.text! == "" || email.text! == "Email Address")
person.email = "Email Address"
else
person.email = email.text
if(mobile.text == "" || mobile.text == "Mobile Number")
person.mobile = "Mobile Number"
else
person.mobile = mobile.text
person.dateCreated = NSDate() as Date
person.priority = 9999
/* STEP 4 - Save the data */
coreDataStack.saveContext()
self.dismiss(animated: true, completion: );
catch
print("Error")
self.dissmissViewController(cancelBtn!)
当我关闭应用程序并再次打开它时,会显示正确的数据。我不太确定这个错误是什么让我想知道从哪里开始研究答案。
【问题讨论】:
【参考方案1】:如果没有更多代码,很难确切地看到发生了什么,但它似乎在告诉您正在递归地保存上下文(即由于某种原因,保存上下文的行为会导致上下文被保存,这导致上下文被保存,这导致上下文被保存....等等)
从调用堆栈看来,这样的事情正在发生:
-
您保存上下文
您正在使用的
FetchedResultsController
收到通知,通知您发生了一些变化。
您的 UITableView
将使用新数据进行更新
显示新单元格的行为会以某种方式触发再次保存上下文。 这就是问题所在 - 这不应该发生。
您正在使用的FetchedResultsController
收到通知,告知您发生了一些变化。
步骤 3-5 永远重复
我会在调用 coreDataStack.saveContext()
的任何地方设置断点,运行应用程序并尝试查看为什么在保存后显示单元格时会递归调用它。
【讨论】:
以上是关于未解决的错误 Error Domain=NSCocoaErrorDomain Code=132001 "(null)"的主要内容,如果未能解决你的问题,请参考以下文章
Dreamhost主机error id: "bad_httpd_conf" 错误如何解决
未处理异常:DatabaseException(Error Domain=FMDatabase Code=26 "file is not a database"。更新到 Flutt
AFNetworking 文件下载错误 Error Domain=NSCocoaErrorDomain Code=260
请求错误 Error Domain=SKErrorDomain Code=0 “操作无法完成。(SKErrorDomain 错误 0。)”
checkResourceIsReachableAndReturnError 总是返回 Domain=NSCocoaErrorDomain Code=4 "操作无法完成。(Cocoa 错误