Почему мой loginAuth
застрял внутри цикла while?
Я объявил connectionFinishLoading
как
@interface LoginViewController : UIViewController {
BOOL connectionFinishLoading;
}
@property (nonatomic, assign) BOOL connectionFinishLoading;
@implementation LoginViewController
@synthesize connectionFinishLoading;
-(BOOL)loginAuth {
NSString *requestString = [NSString stringWithFormat:@"http:myURL?id=%@&format=JSON", userName.text];
NSMutableURLRequest *requestURL = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:requestString]];
loginConnection = [[NSURLConnection alloc] initWithRequest:requestURL delegate:self startImmediately:YES];
[SVProgressHUD showInView:self.view status:@"Logging in"];
while (!connectionFinishLoading) {
NSLog(@"waiting..");
}
// code to executed after connection did finish loading.
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[responseData appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
connectionFinishLoading = YES;
}