- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我得到这个 NSGenericException 原因是 Collection <NSConcreteHashTable: 0x282c34140> was mutated while being enumerated
即使我实际上并没有在我的代码中使用快速枚举。
当 NSFetchedResultsController 委托(delegate)作为我的核心数据对象中的一个属性被调用时,会触发此崩溃,最终调用此方法:
- (void)mutateCoordinatesOfClashingAnnotations:(NSArray *)annotations {
NSDictionary *coordinateValuesToAnnotations = [self groupAnnotationsByLocationValue:annotations]; // returns a dictionary with key: coordinate (saved as NSValue) -> NSMutableArray of MKAnnotation objects
for (int i=0; i<coordinateValuesToAnnotations.allKeys.count; i++) {
NSValue *coordinateValue = coordinateValuesToAnnotations.allKeys[i];
NSMutableArray *outletsAtLocation = coordinateValuesToAnnotations[coordinateValue];
[self repositionAnnotations:outletsAtLocation];
}
}
- (void)repositionAnnotations:(NSMutableArray *)annotations {
for (int i = 0; i < annotations.count; i++) {
double heading = radiansBetweenAnnotations * i;
CLLocationCoordinate2D newCoordinate = [self calculateNewCoordinate];
id <MKAnnotation> annotation = annotations[i];
annotation.coordinate = newCoordinate; // this is where it crashes
}
}
*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <NSConcreteHashTable: 0x282c34140> was mutated while being enumerated.'
Last Exception Backtrace:
0 CoreFoundation 0x00000001c058696c __exceptionPreprocess + 224
1 libobjc.A.dylib 0x00000001c029f028 objc_exception_throw + 56
2 CoreFoundation 0x00000001c05862d4 __NSFastEnumerationMutationHandler + 120
3 libobjc.A.dylib 0x00000001c02b21a4 objc_enumerationMutation + 28
4 Foundation 0x00000001c08706a8 -[NSConcreteHashTable countByEnumeratingWithState:objects:count:] + 72
5 MapKit 0x00000001ce114b64 -[MKAnnotationManager observeValueForKeyPath:ofObject:change:context:] + 804
6 Foundation 0x00000001c093bf14 NSKeyValueNotifyObserver + 288
7 Foundation 0x00000001c093e01c NSKeyValueDidChange + 332
8 Foundation 0x00000001c093b740 NSKeyValueDidChangeWithPerThreadPendingNotifications + 148
9 CoreData 0x00000001c5006e38 _PF_ManagedObject_DidChangeValueForKey + 76
10 Foundation 0x00000001c093784c NSKVOForwardInvocation + 336
11 CoreFoundation 0x00000001c058adc0 ___forwarding___ + 676
12 CoreFoundation 0x00000001c058d3a0 _CF_forwarding_prep_0 + 92
13 CJournal 0x00000001049fc930 -[MapViewShared repositionAnnotations:] (MapViewShared.m:656)
14 CJournal 0x00000001049fc580 -[MapViewShared mutateCoordinatesOfClashingAnnotations:] (MapViewShared.m:616)
15 CJournal 0x0000000104a1fa98 -[MapViewController controllerDidChangeContent:] (MapViewController.m:1104)
16 CoreData 0x00000001c50572a4 __82-[NSFetchedResultsController(PrivateMethods) _core_managedObjectContextDidChange:]_block_invoke + 5868
17 CoreData 0x00000001c5015aac developerSubmittedBlockToNSManagedObjectContextPerform + 160
18 CoreData 0x00000001c4ee01c4 -[NSManagedObjectContext performBlockAndWait:] + 208
19 CoreData 0x00000001c4ee981c -[NSFetchedResultsController(PrivateMethods) _core_managedObjectContextDidChange:] + 120
20 Foundation 0x00000001c095106c __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_2 + 24
21 CoreFoundation 0x00000001c04de99c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 24
22 CoreFoundation 0x00000001c04de9ec ___CFXRegistrationPost1_block_invoke + 64
23 CoreFoundation 0x00000001c04ddce4 _CFXRegistrationPost1 + 392
24 CoreFoundation 0x00000001c04dd97c ___CFXNotificationPost_block_invoke + 104
25 CoreFoundation 0x00000001c0456910 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1420
26 CoreFoundation 0x00000001c04dd2ac _CFXNotificationPost + 1264
27 Foundation 0x00000001c083fbfc -[NSNotificationCenter postNotificationName:object:userInfo:] + 60
28 CoreData 0x00000001c4eed264 -[NSManagedObjectContext(_NSInternalNotificationHandling) _postObjectsDidChangeNotificationWithUserInfo:] + 512
29 CoreData 0x00000001c4ee95fc -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:deletions:updates:refreshes:deferrals:wasMerge:] + 1244
30 CoreData 0x00000001c4ee886c -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 980
31 CoreData 0x00000001c501b48c _performRunLoopAction + 376
32 CoreFoundation 0x00000001c0501524 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
33 CoreFoundation 0x00000001c04fc1c4 __CFRunLoopDoObservers + 416
34 CoreFoundation 0x00000001c04fc774 __CFRunLoopRun + 1288
35 CoreFoundation 0x00000001c04fbf40 CFRunLoopRunSpecific + 476
36 GraphicsServices 0x00000001ca779534 GSEventRunModal + 104
37 UIKitCore 0x00000001c4674a60 UIApplicationMain + 1936
38 CJournal 0x00000001048d8c44 main (main.m:20)
39 libdyld.dylib 0x00000001c037ae18 start + 0
最佳答案
当您更改坐标时,它看起来像 MKAnnotationManager
观察变化,然后通过枚举计算其哈希表,也许您已经在枚举注释。
在任何情况下,您都不应该将模型对象添加到 View 中,这会破坏 MVC。 Controller 的工作是通过注释对象获取模型并将其格式化为 View 。一种方法是创建 MKPointAnnotation
来自您的fetchedObjects
(或创建一个 MKPointAnnotation
子类并使用您的模型对象将其存储在弱属性中进行初始化)并将它们添加到 map 中。在 FRC 的 didChangeObject
您可以从模型对象更新注释。 map 的注释 View 正在对注释的坐标进行 KVO,因此它会自动更新其在 map 上的位置。在您的模型对象上创建一个类别(参见 docs )以存储延迟加载的注释(使用 objc_setAssociatedObject
)。
关于ios - 获取 NSGenericException 原因为 : '*** Collection <NSConcreteHashTable: 0x282c34140> was mutated while being enumerated.' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59836096/
我目前正在尝试弄清楚如何使用iOS 10的AVCapturePhotoOutput方法,但遇到了麻烦。我觉得自己即将做对,但继续收到错误消息: 由于未捕获的异常“NSGenericException”
简单这是我的代码 func showMessageView(){ let leftConstraint = messageView.leftAnchor.constraintEqualToAn
我正在使用 UIImagePickerController 从 iphone 库加载保存的照片。但是当我向上或向下滚动图像时,我的应用程序崩溃了.. 我收到以下错误: 2011-04-21 14:26
我正在使用 NSMutableArray 来存储在我的 View 中显示的一些 UIView 对象。我正在使用 NSTimer 连续调用一个方法来检查该数组的内容并收到一些错误。 这是控制台的堆栈跟踪
这是我在出现 SKScene 时看到的错误,此错误发生随机并且无法复制 * 由于未捕获的异常“NSGenericException”而终止应用程序,原因:“* 集合 在枚举时发生了变异。” 这是怎么回
以下代码: listViewPopoverControllerOL = [[UIPopoverController alloc] initWithContentViewController:myBra
我目前正在尝试弄清楚如何使用 iOS 10 的 AVCapturePhotoOutput 方法,但遇到了困难。我觉得我即将做对,但仍然收到错误: Terminating app due to unca
由于未捕获的异常“NSGenericException”而终止应用 Terminating app due to uncaught exception 'NSGenericException', re
我正在开发一个在 iPhone 上运行的应用程序运行良好,但是当我尝试在 iPad 上运行时它崩溃了 这是我的代码: - (void)parseCountryStates:(NSDictionary
在我的 iPhone 应用程序中,我正在尝试使用 uicollectionView 实现一个图片库。当 was mutated while being enumerated.' *** First
我正在努力寻找和思考这个问题,但我找不到解决它的最佳方案!!我不明白这是什么意思?! Terminating app due to uncaught exception 'NSGenericExcep
我正在使用 [self.view addSubview:myView] 添加一个 View 作为 subview .这在纵向模式下工作正常。但是,它在风景中根本不起作用。如何以编程方式添加布局约束?
我在尝试运行我的应用程序并拍摄照片时不断收到上述错误消息。 我是编程新手,所以如果有人能提供帮助那就太棒了。 这是我的代码 import UIKit import AVFoundation impor
当我的代码如下所示时,我遇到“集合在枚举时发生变化”异常: NSString *poiStr = nil; int SuccessValue=0; NSMutableArray* po
有时我的应用程序因显示 * Collection 在被枚举时发生了变异而崩溃。这一直发生在同一行代码中。请帮助我解决这个问题。我坚持这一点。该应用程序在推送我的代码的 View Controller
我得到这个 NSGenericException 原因是 Collection was mutated while being enumerated 即使我实际上并没有在我的代码中使用快速枚举。 当
我不明白问题所在,但我猜是 Storyboard 中的问题(在我的限制下,因为有时对象不在它们必须在的位置)。 * 由于未捕获的异常“NSGenericException”而终止应用程序,原因:“*
我正在尝试从数组中删除重复的对象。 NSMutableArray* filterResults = [[NSMutableArray alloc] init]; BOOL copy;
我正在使用 Alamofire,在我的应用程序在模拟器上运行几个小时后,我遇到了崩溃并出现此错误。 *** Terminating app due to uncaught exception 'NSG
所以我正在制作一个包含 5 个 View Controller 的应用程序,第一个嵌入在 UINavigationController 中,前 4 个 View Controller 之间的连接工作正
我是一名优秀的程序员,十分优秀!