So i have this function that parses data from an url string and set labels.
- (void)viewDidLoad
{
[super viewDidLoad];
[self parseAndSetLabels];
}
The problen is that if you have a bad connection it can take a while and it look likes the app froze, but it actually do the parseAndSetLabels function before it animates the view.
So how can i make the viewLoad and after that run my function ?
(like in this order)
-(void)main
{
[self viewDidLoad]
[self parseAndSetLabels];
}
As Nickolay O. said, use
NSURLConnectionasynchronously with its delegate methods or you can callparseAndSetLabelsmethod in yourviewDidAppear:method.Placing your call inside this last method, it will be called every time the view appears but if you don’t want this, you can use simple boolean conditions to call this method only once, like in this example:
However, in your case,
NSURLConnectionand its delegate are the best solutions.