AFNetworking 异步请求远程数据

zoutian00 2015-05-12

- (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);
    }];

}

相关推荐

倾城一屁博妹一笑 / 0评论 2014-01-15