I have the following code that fetches some data from a php script. I m finding that it blocks the interface so that the progress indicator doesn t spin. Is there an easy way to send this to the background so that the UI is free to do whatever it needs? I was under the impression that using blocks would have achieved this but I was obviously wrong (learning Obj-C one step at a time!)
感谢!
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
self.user.username, @"username",
self.user.password, @"password",
nil];
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:
[NSURL URLWithString:@"http://domain.com"]];
// Show animated progress indicator, etc
[self enbleLoadingState:YES];
[client postPath:@"/en/api/login" parameters:params success:^(AFHTTPRequestOperation *operation, id response) {
[self enbleLoadingState:NO];
// Do stuff
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[self enbleLoadingState:NO];
// Show error
}];