- (void)Get{
//设置请求任务
NSURLSessionTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://web.juhe.cn:8080/finance/gold/shgold?key=1b9f570e367ce24e51135d69eac7d04e&v=1"]] completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (error) {
NSLog(@"请求失败");
}else{
NSLog(@"%@",[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];
NSArray *AD = dic[@"result"];
NSDictionary *div =AD[0];
for (NSString *k in [div allKeys]) {
[arrTile addObject:k];
Model *mode = [[Model alloc] init];
[mode setValuesForKeysWithDictionary:div[k]];
[arrData addObject:mode];
}
dispatch_async(dispatch_get_main_queue(), ^{
[tbv reloadData];
});
}
}] ;
[task resume];
}