我正在提出一個有時會返回錯誤消息示例錯誤的請求:「沒有現場遊戲」。檢查valueForKey是否存在
如何檢查valueforkey:error是否存在?
僞
if (error exists) {
//nothing
} else {
//return other value for keys
}
我的要求
NSDictionary* headers3 = @{@"X-Mashape-Authorization": @"key"};
NSDictionary* parameters3 = @{};
UNIHTTPJsonResponse* response3 = [[UNIRest get:^(UNISimpleRequest* request3) {
[request3 setUrl:@"https://willjw-statsfc-competitions.p.mashape.com/live.json?key=uNzRmnUdCEYKdOoe1e1bBpwtmczNVLUZYbIlOX9O&competition=europa-league&timezone=Europe%2FLondon"];
[request3 setHeaders:headers3];
[request3 setParameters:parameters3];
}] asJson];
NSData* rawBody3 = [response3 rawBody];
results3 = [NSJSONSerialization JSONObjectWithData:rawBody3 options:NSJSONReadingMutableContainers error:nil];
顯示成功和錯誤條件的樣本JSON .. – Wain