i didn't really know how to title this question, but here's a thing that really kills me: In my app i have a UITableView, UISegmentedControl and UINavigationBar. Once UISegmentedControl gets one of its segments selected i want to show a UIActivityIndicatorView on the UINavigationBar and then parse an xml file and present the results in a table. Everything works almost as i want it to, except one thing, the activity indicator view gets added to the uinavigationbar after the parser finishes, even though the method showLoading that adds UIIndicatorView to UINavigationBar gets before parser is initialised. Can anyone explain it? is there something i might be missing? maybe the ui needs to get redrawn? thanks peter
Asked
Active
Viewed 358 times
1 Answers
0
It looks that you parse your xml in main thread and so it becomes blocked for UI changes. Try to move xml parsing to separate thread (e.g. by calling your parsing method via -performSelectorInBackground:
)
Edit: Actually you're (almost certainly) using autorelease
implicitly in your application - as many standard functions return autoreleased objects. When you're running your functions on separate thread you need to create NSAutoreleasePool
object there to handle autoreleased objects and avoid memory leaks (see Autorelease Pools in docs). So your parseXML function must look like:
- (void)parseXML{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
... //xml parsing routines etc
[pool release];
}

Vladimir
- 170,431
- 36
- 387
- 313
-
Hi! thanks so much for answer, but now when i tried parsing with performSelectorInBackground i get a bunch of NSAutoreleaseNoPool errors, even though i'm not using autorelease at all in the app. – dusker Mar 09 '10 at 10:24
-
Hi again, actually for some weird reason the errors are also about some UI elements of the main view (for the reference i call the parser in the other class). greetings – dusker Mar 09 '10 at 11:24
-
what kind of errors they are? May be it is better to ask about them in separate question if the problems with activity indicator and memory leaks are solved? – Vladimir Mar 09 '10 at 11:38
-
it's the errors about leakage, but they address some UI elements of a class that has the object that parses xml – dusker Mar 09 '10 at 12:13