Lachtan
Lachtan

Reputation: 5172

Preload data from xml, table view doesn't reload

I have following problem. In my app I'm downloading .xml file from server and then parsing it. I call both methods (get and parse) from application:willFinnishLaunchingWithOptions.

Right after parsing is posted notification. In main table view controller is observer and selector is supposed to reload table view. But it doesn't. ViewDidLoad in TVC is called before parsing is completed, also before launching screen disappears.

So my question is: Is possible to freeze application:didFinishLaunchingWithOption till all data are parsed? Thanks

Upvotes: 0

Views: 35

Answers (1)

Björn Ro
Björn Ro

Reputation: 780

No its not possible. What you could do: Don't show your TVC. Show a loading Controller. This Controller will do the work with loading the data and parsing it. When its done you can call your TVC

For Example:

  1. LoadingController has a instance of a Manager Class
  2. The Manager downloads your file. ( Extra Communicator or something else)
  3. Your provide success and failure blocks to the manager calls. Means, build a function with func downloadXML(success: blockStuff, failure: blockstuff). In the success your provide the parsing
  4. When parsing is finished you show your TBV with the data

Feel free to ask or comment :)

Upvotes: 1

Related Questions