난 내 응용 프로그램을 실행하려고 노력하지만, 내가 가지고 콘솔에 던져 예외를 가지고이 :'NSException'
2011-05-05 00:18:50.984 myApp[2906:207] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x6b8b780> was mutated while being enumerated.(
"<MyLocation: 0x6b67af0>",
"<MyLocation: 0x6b19360>",
"<MyLocation: 0x6b67a70>",
"<MyLocation: 0x6b8d110>",
"<MyLocation: 0x6b8d280>",
"<MyLocation: 0x6b8ce50>",
"<MyLocation: 0x6b8d660>"
)'
*** Call stack at first throw:
(
0 CoreFoundation 0x02915919 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0272a5de objc_exception_throw + 47
2 CoreFoundation 0x029153d9 __NSFastEnumerationMutationHandler + 377
3 myApp 0x00005755 -[StationsSurLaCarteViewController requestFinished:] + 343
4 myApp 0x000195cb -[ASIHTTPRequest reportFinished] + 171
5 Foundation 0x000abe9a __NSThreadPerformPerform + 251
6 CoreFoundation 0x028f6d7f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
7 CoreFoundation 0x028552cb __CFRunLoopDoSources0 + 571
8 CoreFoundation 0x028547c6 __CFRunLoopRun + 470
9 CoreFoundation 0x02854280 CFRunLoopRunSpecific + 208
10 CoreFoundation 0x028541a1 CFRunLoopRunInMode + 97
11 GraphicsServices 0x02e8e2c8 GSEventRunModal + 217
12 GraphicsServices 0x02e8e38d GSEventRun + 115
13 UIKit 0x0033ab58 UIApplicationMain + 1160
14 myApp 0x0000224c main + 102
15 myApp 0x000021dd start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
(gdb)
내가 가지고 것으로 나타났습니다 그 이후 내가 사전 :
편집에서 들으 도와 줘요 내지도보기 위해 주석을 사용하려고
이 문제를 만들 수있는 내 for
루프 :
for (int i=0; i<[array count]; i++) {
NSDictionary *stationEnCours=[array objectAtIndex:i];
NSString *distance=[stationEnCours objectForKey:@"distance"];
float lng = [[stationEnCours objectForKey:@"ssiphone_longitude"] floatValue];
float lat = [[stationEnCours objectForKey:@"ssiphone_latitude"] floatValue];
NSString *ensStation=[stationEnCours objectForKey:@"ssiphone_enseigne"];
location2D = (CLLocationCoordinate2D){ .latitude = lat, .longitude = lng };
MyLocation *annotation=[[[MyLocation alloc]initWithName:ensStation distanceVersLaStation:distance coordinate:location2D]autorelease];
[mapView addAnnotation:annotation];
MKCoordinateSpan span={latitudeDelta:0.2,longitudeDelta:0.2};
MKCoordinateRegion region={location2D,span};
[mapView setRegion:region];
[self.view addSubview:mapView];
}`
안녕하세요, 제 편집을 보시기 바랍니다. 'for'loop의 문제점을 볼 수 없지만, 메모리 관리가 누락 되었습니까? – Luca
루프가 충돌을 일으키고 있습니까? 찾으려는 것은'for (in)'문법을 사용하고,'in' 다음에 명명 된 배열을 변경해야합니다. 그 루프가 문제라면 다른 스레드도 실행중인 또 다른 루프가 발생합니다. – ughoavgfhw