0

I have a image view which sets to image after loading from the server in one of my project. I see some time crashes where stacktrace looks like this

CoreFoundation 0x344d82a3 __exceptionPreprocess + 163   
libobjc.A.dylib 0x3c1bc97f objc_exception_throw + 31    
CoreFoundation 0x344d7d85 -[NSException name] + 1   
Foundation 0x34d78509 -[NSConcreteMapTable countByEnumeratingWithState:objects:count:] + 57 
CoreFoundation 0x34460d39 -[__NSFastEnumerationEnumerator nextObject] + 133 
CoreFoundation 0x34433f11 -[NSEnumerator countByEnumeratingWithState:objects:count:] + 49   
Foundation 0x34e88093 -[NSISEngine enumerateRows:] + 215    
Foundation 0x34e8dfdf -[NSISEngine description] + 123   
CoreFoundation 0x34448897 -[NSObject(NSObject) _copyDescription] + 35   
CoreFoundation 0x344b92db __CFStringAppendFormatCore + 11139    
CoreFoundation 0x34453fa9 CFStringCreateWithFormatAndArguments + 73 
CoreFoundation 0x344d8195 +[NSException raise:format:] + 57 
Foundation 0x34e8a11f -[NSISEngine minimizeConstantInObjectiveRowWithHead:] + 191   
Foundation 0x34e8c759 -[NSISEngine optimize] + 61   
Foundation 0x34e8c8af -[NSISEngine withAutomaticOptimizationDisabled:] + 211    
UIKit 0x36719c4f -[UIView(UIConstraintBasedLayout) removeConstraints:] + 283    
UIKit 0x362f6451 -[UIView(UIConstraintBasedLayout) invalidateIntrinsicContentSize] + 73 
UIKit 0x362f4f39 -[UIImageView setImage:] + 381 
MyApp 0x000ae369 -[DetailViewController didLoadImage:contextInfo:] (DetailViewController.m:1722)    
MyApp 0x00114a45 -[UTImageCache executeRequest:] (UTImageCache.m:296)   
Foundation 0x34deee85 __NSThread__main__ + 973  
libsystem_c.dylib 0x3c613311 _pthread_start + 309   
libsystem_c.dylib 0x3c6131d8 thread_start + 8

And the crash message is

18-Sep-13 04:43:28 PM NSGenericException
* Collection was mutated while being enumerated.

I am not sure what is the issue here? Is the Auto layout is making any issue here.

Thanks

Naveen
  • 636
  • 8
  • 28
  • http://stackoverflow.com/questions/3446983/collection-was-mutated-while-being-enumerated-on-executefetchrequest – iPatel Sep 19 '13 at 06:44
  • 3
    Hmm. The asker doesn't write something about Core Data or threads. – dasdom Sep 19 '13 at 06:46
  • @iPatel: It is nothing to do with core data – Naveen Sep 19 '13 at 07:30
  • Looks like a race condition in UIKit internals. Is this the main thread, or is this executing on a secondary thread? – CouchDeveloper Sep 19 '13 at 08:36
  • @CouchDeveloper: It's on main thread, its a main thread stacktrace – Naveen Sep 19 '13 at 09:21
  • Hm, after looking even more closely, it seems there are two exceptions, the latter thrown while creating a description of the first. The first exception occurs in `-[NSISEngine minimizeConstantInObjectiveRowWithHead:]`. Did you set auto layout directives in code, utilizing "Visual Format Language"? – CouchDeveloper Sep 19 '13 at 09:41
  • I didn't understand what is "auto layout directives in code", can you please provide more info on this? – Naveen Sep 19 '13 at 10:36

1 Answers1

1

No, it's not auto layout. It seems that you have something like

for (NSDictionary *dictionary in myAwesomeArray) {

}

in your code. If you iterate over the contents of an array you are not allowed to alter the array. This is what you are doing according to the error message.

allprog
  • 16,540
  • 9
  • 56
  • 97
dasdom
  • 13,975
  • 2
  • 47
  • 58
  • Yes, my initial investigation pointed out on the array issue as it says, but I rechecked and didn't show find any issue in the code. Also what strange thing observed is why the crash report pointing at setImage: API? I am not sure how it is related here. – Naveen Sep 19 '13 at 07:51