Can you please help me to find reason why my app crashes after clicking on segmented control? Not allways, but usualy after some clicks.
Error message:
I think the problem is in these line of code
for (NSString *file in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL])
{
[[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
}
and you are using it in two methods didLoad and didUnload. The reason that you are getting because you are updating the content of the following array
[[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL]
When you go thorough enumerator class you will get this caution of "not updating the content while enumerator is in use" ... So to overcome this problem simply do following to all the places where you have used this code....
NSArray* temp = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:NSTemporaryDirectory() error:NULL];
for (NSString *file in temp)
{
[[NSFileManager defaultManager] removeItemAtPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), file] error:NULL];
}
i hope this would solve your problem...
Looks like the problem was with UIImagePickerController and only in simulator (more described in details here: http://blog.airsource.co.uk/index.php/2008/11/12/memory-usage-in-uiimagepickercontroller/ ). On real device everything works quite fine.
solved
I had same problem in coredata objects enumeration.
Do not change sub object which relies in ARRAY on which Loop is Running
Like ==>>
If I change/Modify object while in loop, it will give this error.
for (LoadList *objLL in ArrLoadList) { // here Enumaration is Going on
// here I removed objects in ArrLoadList and reassign the ArrLoadList ..
// it will give me this error
// So Don't change the Main Array object
}