2011-09-23 196 views
-4

終止應用程序由於未捕獲的異常「NSGenericException」,原因是:「*收藏< __NSArrayM:0x175800>突變而被枚舉這個錯誤的原因是什麼?

+0

可能重複[獲取異常爲「集合在枚舉時發生了變化」](http://stackoverflow.com/questions/3424861/getting-exception-as-collection-was-mutated-while-being- enumerated) –

回答

3

你改變一個可變的數組,而你遍歷它。你不能那樣做。一種解決方案可能是迭代數組的副本,但這取決於你在做什麼。

+0

- (IBAction)getCameraPicture:(id)sender { \t UIImagePickerController * picker = [[UIImagePickerController alloc] init]; \t picker.delegate = self; // \t picker.allowsImageEditing = NO; \t picker.sourceType =(sender == takePictureButton)? UIImagePickerControllerSourceTypeCamera: \t UIImagePickerControllerSourceTypeSavedPhotosAlbum; \t [self presentModalViewController:picker animated:YES]; \t [picker release]; } 我在此相機中出現錯誤按鈕操作錯誤 –

+0

如果您有新問題,則應將其作爲新問題發佈,而不是對答案發表評論。 – Jim

-1

這個錯誤通常發生在使用快速枚舉的時候試圖改變數組。要麼使用傳統的循環..或標記你想變異的對象,並在完成枚舉後完成。

相關問題