我需要显示一个页面,但使用很多接口

时间:2016-03-17 09:58:36

标签: ios

我使用tableview来显示它,但由于有很多接口,我不知道何时重新加载数据。我已经重新加载了每个请求的数据。但这会导致屏幕溢出。我感谢使用gcd ,但效果不好。我需要你的帮助,谢谢。 我的应用程序有一些代码: ASISafeRelease(_getMainPicRequest) ASISafeRelease(_newsListRequest) ASISafeRelease(_articleListRequest) ASISafeRelease(getNewsCountReq) ASISafeRelease(getResouceCountReq) ASISafeRelease(getArticelCountReq) ASISafeRelease(getActiveCountReq) //the first request NSMutableDictionary * getMainPic = [NSMutableDictionary dictionary]; _getMainPicRequest = [HttpRequsetFactory getRequestKeys:getMainPic subUrl:SUB_URL_GETMAINPIC userCommon:YES]; [_getMainPicRequest setDelegate:self]; [_getMainPicRequest setDidFinishSelector:@selector(finish:)]; [_getMainPicRequest setDidFailSelector:@selector(fail:)]; [_getMainPicRequest startAsynchronous]; //the secode request NSMutableDictionary * dic = [NSMutableDictionary dictionary]; [dic setObject:@"1" forKey:@"typeId"]; [dic setObject:@(1) forKey:@"page"]; [dic setObject:@(1) forKey:@"pageSize"]; _newsListRequest = [HttpRequsetFactory getRequestKeys:dic subUrl:SUB_URL_NEWSLIST userCommon:YES]; [_newsListRequest setDelegate:self]; [_newsListRequest setDidFinishSelector:@selector(finish:)]; [_newsListRequest setDidFailSelector:@selector(fail:)]; [_newsListRequest startAsynchronous];// the third request NSMutableDictionary * articleDic = [NSMutableDictionary dictionary]; [articleDic setObject:@"1" forKey:@"typeId"]; [articleDic setObject:@"0" forKey:@"isGroupArticle"]; [articleDic setObject:@"0" forKey:@"recvId"]; [articleDic setObject:@(1) forKey:@"pageSize"]; [articleDic setObject:@"0" forKey:@"sort"]; [articleDic setObject:@(1) forKey:@"page"]; _articleListRequest = [HttpRequsetFactory getRequestKeys:articleDic subUrl:SUB_URLARTICLELIST userCommon:YES]; [_articleListRequest setDelegate:self]; [_articleListRequest setDidFinishSelector:@selector(finish:)]; [_articleListRequest setDidFailSelector:@selector(fail:)]; [_articleListRequest startAsynchronous]; //the forth request [self getnewscount]; //the fifth request [self getresoucecount]; enter code here //the sixth request [self getarticelcount]; //the seventh request [self getactivecount]; [self creatHUD:LOCALIZATION(@"is_loading")]; [HUD show:YES];

//request fail 
- (void)fail:(ASIFormDataRequest *)request{
    [HUD hide:YES];
    NSLog(@"request fail");
}

}`

//request suc - (void)finish:(ASIFormDataRequest *)request{ NSString *response = [[NSString alloc] initWithData:request.responseData encoding:NSUTF8StringEncoding]; NSDictionary *dic = [response JSONValue]; //NSLog(@"---------dic = %@",dic); if (request.responseStatusCode == 200 && [[NSString stringWithFormat:@"%@",[dic objectForKey:CKEY]]isEqualToString:SUC_CKEY])

{ NSDictionary * model = [dic[@"newslist"]lastObject]; [_newsArray addObject:model]; [_myTableView reloadData]; } {         if(request == _newsListRequest){ NSDictionary * model = [dic[@"articlelist"]lastObject]; [_articleArray addObject:model]; [_myTableView reloadData]; } else if(request == _articleListRequest)// WelPicModel * welModel = [[WelPicModel alloc]initWithDic:dic]; // [_imageArray addObject:welModel]; _imageArray = [NSMutableArray arrayWithArray:[WelPicModel makeWelPicModels:[dic objectForKey:@"mainpic"]]]; else {

[HUD hide:YES]; [_myTableView reloadData]; } }

dev dependencies

}

0 个答案:

没有答案