I have been trying to add a button after a parser ( on a seperate thread ) is complete. I understand you cannot interact with UI elements on any thread other than the main thread.
I do not want to use a timer, or a while statement... so my question is
Once the parser is done what do you suggest I do to add the button to the view? I do not want it added before because the user will get to a blank table. I also do not want to reload the table when done because the presents other problems for me.
the performSelector on main thread does not seem to work for me either.. ? Im kind of lost here...
Any suggestions?
Here is where I kick off to another thread to start parser (In AppDelegate)
// begin background downloads
[NSThread detachNewThreadSelector:@selector(parseNewData) toTarget:self withObject:nil];
My parseNewData function (In AppDelegate)
-(void)parseNewData {
//start network activity spinner and release controller when done
RootViewController * root = [[RootViewController alloc] init];
[root downloadIcon];
[root release];
//create pool to avoid memory leak
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// get the XML path and start parsing
NSURL *pathURL = [NSURL URLWithString:@"http://www.mysite.com/file.xml"];
NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:pathURL];
[parser setDelegate:self];
[parser parse];
//drain pool
[pool drain];
[pool release];
}
Parser Did Finish (In AppDelegate)
- (void)parserDidEndDocument:(NSXMLParser *)parser
{
// parser is finished, we can now kill the network activity icon on root view controller
RootViewController * root = [[RootViewController alloc] init];
[root killDownloadIcon];
[root performSelectorOnMainThread:@selector(unhideShowtimesButton) withObject:nil waitUntilDone:NO];
[root release];
}
My unhideShowtimesButton on ( in RootViewController )
-(void)unhideShowtimesButton {
showtimesButton.hidden = FALSE;
}
I am making it to my unhideShowtimesButton (verified by break point) but its just completely ignoring the hidden = False.