2012-05-18 17:17:52.990 Untitled [982:207] *** Terminating app due to uncaught exception 'NSGenericException', reason: '** * Collection <__NSArrayM: 0x615c6a0> was mutated while being enumerated. (
{
img = "GunKing.png";
name = "\ U67aa \ U738b \ U4e4b \ U738b";
time = "01:30:20";
},
{
img = "panda.png";
name = "\ U529f \ U592b \ U718a \ U732b";
time = "01:50:50";
},
{
img = "pary.png";
name = "\ U5efa \ U515a \ U4f1f \ U4e1a";
time = "02:11:00";
}
) '
*** Call stack at first throw:
(
0 CoreFoundation 0x00fa55a9 __ exceptionPreprocess + 185
1 libobjc.A.dylib 0x010f9313 objc_exception_throw + 44
2 CoreFoundation 0x00fa5069 __ NSFastEnumerationMutationHandler + 377
3 CoreFoundation 0x00f0b1eb - [__NSFastEnumerationEnumerator nextObject] + 75
4 Untitled 0x000022c3 - [RootviewAppDelegate getDictonary:] + 288
5 Untitled 0x0000a6ba - [DetailsViewController collectButtonPress] + 386
6 UIKit 0x002d14fd - [UIApplication sendAction: to: from: forEvent:] + 119
7 UIKit 0x00361799 - [UIControl sendAction: to: forEvent:] + 67
8 UIKit 0x00363c2b - [UIControl (Internal) _sendActionsForEvents: withEvent:] + 527
9 UIKit 0x003627d8 - [UIControl touchesEnded: withEvent:] + 458
10 UIKit 0x002f5ded - [UIWindow _sendTouchesForEvent:] + 567
11 UIKit 0x002d6c37 - [UIApplication sendEvent:] + 447
12 UIKit 0x002dbf2e _UIApplicationHandleEvent + 7576
13 GraphicsServices 0x018fd992 PurpleEventCallback + 1550
14 CoreFoundation 0x00f86944 __ CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
15 CoreFoundation 0x00ee6cf7 __ CFRunLoopDoSource1 + 215
16 CoreFoundation 0x00ee3f83 __ CFRunLoopRun + 979
17 CoreFoundation 0x00ee3840 CFRunLoopRunSpecific + 208
18 CoreFoundation 0x00ee3761 CFRunLoopRunInMode + 97
19 GraphicsServices 0x018fc1c4 GSEventRunModal + 217
20 GraphicsServices 0x018fc289 GSEventRun + 115
21 UIKit 0x002dfc93 UIApplicationMain + 1160
22 Untitled 0x00002180 main + 102
23 Untitled 0x00002111 start + 53
)
terminate called after throwing an instance of 'NSException'
if ([m_array count]! = 0)
{
NSEnumerator * enumerator = [m_array objectEnumerator];
NSDictionary * testDic;
while ((testDic = [enumerator nextObject]))
{
if ([testDic isEqualToDictionary: m_dictionary])
{
continue;
}
else
{
[M_array addObject: m_dictionary];
}
}
enumerator = nil;
}
else
{
[M_array addObject: m_dictionary];
}
Internet search a bit, because improper use NSEnumerator. Is it because the addition of an array of data leads to change, so that address cross-border?
If I want to continue to use
NSEnumerator reach a traverse effect, how should be modified. Thank you
Reply:
. . . The same title. .
When we do the traversal, it is best not to modify the original data to traverse the traversal process, if you want to modify try to use a for loop,
If for example, when traversing to modify your code has [m_array addObject: m_dictionary]; such statement may be the cause of the anomaly.
If you must use Enumerator traverse but also to modify, you can then declare an array of intermediate variables, such as traversal after the end of the data to be modified. . .
No comments:
Post a Comment