当前位置:首页 > 开发 > 移动开发 > 正文

AFNetworking 异步请求远程数据

发表于: 2015-05-12   作者:BlueSkator   来源:转载   浏览:
摘要: - (void) sendRequestByNet:(NSString *) beginNum setDepartId:(NSString *)departmentId { NSString *url = @"url"; NSMutableDictionary *parameters = [NSMutableDictionary diction
- (void) sendRequestByNet:(NSString *) beginNum setDepartId:(NSString *)departmentId
{
    NSString *url = @"url";
    
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    parameters[@"req_number"] = beginNum;
    parameters[@"departmentID"] = departmentId;
                                        

    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/json", @"text/plain", @"text/html", nil];

    [manager GET:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSArray *resArr = responseObject;
        for(NSDictionary *dict in resArr){
            SkNewsFrame *frame = [[SkNewsFrame alloc]init];
            SkNews *news = [SkNews newsWithDict:dict];
            frame.news = news;
            [_newsFrameArray addObject:frame];
        }
        [self.SksNewsTableView reloadData];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"error -- %@",error);
    }];

}

 

AFNetworking 异步请求远程数据

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号