发送请求JSON解析自带

来源:互联网 发布:手机淘宝在哪开店 编辑:程序博客网 时间:2024/05/22 07:08

-(void)loadData

    NSString *str =@"http://xxx.com";

    ASIFormDataRequest *requst = [ASIFormDataRequestrequestWithURL:[NSURLURLWithString:str]];

    [requst setCompletionBlock:^{

       NSError* error = nil;

        NSDictionary* dic = [NSJSONSerializationJSONObjectWithData:[requst responseData]options:kNilOptionserror:&error];

       if (error) {

            NSLog(@"NSJSONSerialization error : %@", [errorlocalizedDescription]);

           return;

        }

       NSArray* arrData = [dic objectForKey:@"elements"];

       for (NSDictionary* dicTempin arrData) {

           SFData* sf = [[SFDataalloc]initWithdic:dicTemp];

            [_arrDataListaddObject:sf];

        }

        [self.tableViewreloadData];

    }];

    [requst startSynchronous];

    

}


原创粉丝点击