我有以下的代碼,但不能確定爲什麼它不運行:NSURLSession performSegueWithIdentifier沒有運行
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithURL:
[NSURL URLWithString:myURLString] completionHandler:^
(NSData *data, NSURLResponse *response, NSError *error)
{NSDictionary *json =
[NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
[self performSegueWithIdentifier:@"login" sender:self];}];
[dataTask resume];
的preformSegueWithIdentifier工作外而不是括號內。但我使用NSUrlConnection做了類似的工作,並且工作正常。我是NSURLSession的新手,爲什麼performSegueWithIdentifier沒有在調用中運行。
任何想法?
看看這個問題。 http://stackoverflow.com/questions/5023566/objective-c-calling-self-methodname-from-inside-a-block – Michael