1
當我第一次完成這段代碼沒有互聯網連接時,它顯示警告應該如何。但是,當我首次成功完成互聯網連接並關閉互聯網連接後,所有下一次執行都將以相同的響應對象成功完成。沒有在設備上嘗試過,只有iOS模擬器。爲什麼AFNetworking在沒有互聯網連接的情況下成功運行?
NSString *string = @"https://money.yandex.ru/api/categories-list";
NSURL *url = [NSURL URLWithString:string];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = [AFJSONResponseSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
[self deleteAllObjects];
self.numberOfBranchObjects = 0;
for (NSString *key in (NSDictionary *)responseObject) {
[self insertNewObject:key fromSender:self];
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error Retrieving Weather"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
}];
[operation start];
它是在AFNetworking響應對象或smth其他任何緩存?
感謝:
然後之前調用此方法!公牛的眼睛!按我的意願工作。 – Filinovi4