开发者

iphone : how to preload data at a certain time of application loading, just after awakeFromNib method

开发者 https://www.devze.com 2022-12-12 11:58 出处:网络
in my (quite simple) application, --> i have one subview (named \"Splash\") loaded in the main view at launch time, like this (in my mainView class) :

in my (quite simple) application,

--> i have one subview (named "Splash") loaded in the main view at launch time, like this (in my mainView class) :

-(void)awakeFromNib{
 [self addSubview:splash];
}

--> I have also a UITableView (named "myTable") loaded by clicking a button (which calls the IBAction named "LoadData:") in the subview "splash". (all views are made in interfaceBuilder, and each views have their corresponding classes in the xCode project)

What i want to do is to preload (cache) large amount of data (750 entries) from a SQLite database, before i load the second subView ("myTable"), which is using this data stored in an array.

To perform this, i have a method called "RefreshData:", which is called at a certain time to store the results in an array. This array is used in the UITableView to show this data. All is running perfectly well, but...

  • if i call "RefreshData" method at the end of the "awakeFromNib" method 开发者_开发百科in the "mainView" class, my app takes ~15 seconds to show the first screen (named "splash") : not good.
  • if i call "RefreshData" within the IBAction "LoadData", the UITableView takes ~13 seconds to appear on screen : not good at all.

So, the question is : is there a way to call the "RefreshData" method AFTER the first subView ("splash") did appear on screen, and BEFORE user clicks on the button which loads the UITableView ?

Any help will be appreciated, and please apologizes for my bad english !


Try calling refreshData a little later ie in

-(void) viewDidAppear:

Also if the SQL request is locking up the GUI you should perhaps think about pulling the data off in a new thread (although I thought SQL did this)

0

精彩评论

暂无评论...
验证码 换一张
取 消