0

My iOS app has a welcome screen (not to be confused with the default view). The view controller downloads and parses an XML file using NSXMLParser. When it completes it's task it makes a button visible, which when clicked calls "presentViewController" which takes the user into the actual app. This worked fine.

I then decided that I would just like the the app to automatically transition, and so I removed the button altogether and moved the call to presentViewController into the "parserDidEndDocument" delegate method. The method gets called but nothing happens. I suspect it has something to do with the context, but when I log "self" it prints an instance of the welcome view controller. What am I doing wrong? How should I fix this?

Groppe
  • 3,819
  • 12
  • 44
  • 68

1 Answers1

4

Try dispatching it to the main thread. Async objects like NSXmlParser work on separate threads, but UIKit updates must be done on the main thread.

dispatch_async(dispatch_get_main_queue(), ^{
    [self presentViewController]; //Or whatever
});
borrrden
  • 33,256
  • 8
  • 74
  • 109
  • That worked! Thanks. However, I am now getting this warning: "Unbalanced calls to begin/end appearance transitions for ." – Groppe Jul 10 '12 at 09:00
  • Make sure you are not calling it multiple times. Also there are tons of answers about this problem on SO. – borrrden Jul 10 '12 at 09:01