gpt4 book ai didi

ios - 异步 Asihttprequest

转载 作者:行者123 更新时间:2023-11-29 12:52:08 30 4
gpt4 key购买 nike

我想异步显示数据,它工作成功并且我在我的日志消息中很快得到响应但是隐藏微调器需要太多时间,而且我无法快速将数据显示到我的 TableView 中,我能知道什么是原因是什么?

-(void) clubsDetail:(int)catID
{

NSString *link = [NSString stringWithFormat:@"%@",KWSURLVenu];
NSLog(@"%@",link);

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:link]];
[request setRequestMethod:@"POST"];

[request setPostValue:[NSString stringWithFormat:@"%d", catID] forKey:@"cat_id"];
NSLog(@"%d",catID);
[request setCompletionBlock:^{
NSString *jsonString = [request responseString];
NSLog(@"response %@",jsonString);
NSArray *dataArray = (NSArray *) [jsonString JSONValue];
NSDictionary * returnDicto = nil;
NSLog(@"response after parsin");
// NSDictionary * returnDict = [returnDicto objectForKey:@"club_info"] ;

[slideDetail_dataArray removeAllObjects];
// if ([returnDict objectForKey:@"club_info"]) {


for(returnDicto in dataArray)
{
PostClubDC *postDC = [[PostClubDC alloc] init];
NSDictionary * returnDict = [returnDicto objectForKey:@"club_info"] ;
postDC.postID = [[returnDict objectForKey:@"Id"]integerValue];
postDC.postCatID = [[returnDict objectForKey:@"cat_id"]integerValue];
postDC.postName = [returnDict objectForKey:@"name"];
postDC.postHeadLine = [returnDict objectForKey:@"headline"];
postDC.postImage = [returnDict objectForKey:@"image"];
postDC.postLat = [returnDict objectForKey:@"long"];
postDC.postAddress = [returnDict objectForKey:@"address"];
postDC.postSummary = [returnDict objectForKey:@"summary"];
postDC.postStat = [returnDict objectForKey:@"stat"];
postDC.postUS = [returnDict objectForKey:@"us"];
NSDictionary * returnDictic = [returnDicto objectForKey:@"club_rating"];
postDC.postGoodRate = [returnDictic objectForKey:@"good"];
postDC.postGreatRate = [returnDictic objectForKey:@"great"];
[slideDetail_dataArray addObject:postDC];
}

// hide spinner
[[myActivityIndicator currentIndicator]hide];
[tbl_slideDetail reloadData];
}];
// [request setFailedBlock:^{
// NSError *error = [request error];
// }];
[request startAsynchronous];
// show spinner

[[myActivityIndicator currentIndicator] displayActivity:@"Loading"];
}

最佳答案

我认为您的问题是您正试图从主线程以外的线程更改 UI。尝试更改此代码以查看是否有帮助:

    // hide spinner
dispatch_async(dispatch_get_main_queue(), ^{
// hide spinner on main thread
[[myActivityIndicator currentIndicator]hide];
[tbl_slideDetail reloadData];
});

关于ios - 异步 Asihttprequest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22195061/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com