2011-09-23 159 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

这个错误通常发生在使用快速枚举的时候试图改变数组。要么使用传统的循环..或标记你想变异的对象,并在完成枚举后完成。

相关问题