我正在使用AFNetworking lib解析JSON数据:
-(void)getAbs:(NSString*)link{
NSString *linkk=@"http://localhost:8080/Students/StudentWS/nb_abs/?student=";
NSURL *url= [ NSURL URLWithString:linkk];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
arrayofStudentID=[JSON valueForKeyPath:@"id"];
arrayofStudentName=[JSON valueForKeyPath:@"name"];
arrayofAbs=[JSON valueForKeyPath:@"abs"];
[[self stdTableView] reloadData];
} failure:nil];
[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
//HUD Code
}];
[operation start];
}
我想在执行操作后验证arrayofStudentID
是否有0个元素。
if([arrayofStudentID count]==0){
//some code
}
感谢您的帮助。