作为学习经验,我想创建一个iPhone应用程序,它调用and服务器/and服务,检索JSON响应,并使用该响应填充UITableView
的行(假设它首先将JSON转换为NSArray
)。
有谁知道什么可能有用的东西吗?
发布于 2011-04-28 11:19:03
发布于 2012-03-30 03:08:18
从JSON5.0开始,苹果提供了NSJSONSerialization class“将iOS转换为基础对象,并将基础对象转换为JSON”。没有外部框架可以整合,根据benchmarks的说法,它的性能非常好,明显优于SBJSON。
发布于 2013-04-11 17:41:43
SBJSON *parser = [[SBJSON alloc] init];
NSString *url_str=[NSString stringWithFormat:@"Example APi Here"];
url_str = [url_str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:url_str]];
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *json_string = [[NSString alloc] initWithData:response1 encoding:NSUTF8StringEncoding]
NSDictionary *statuses = [parser2 objectWithString:json_string error:nil];
NSArray *news_array=[[statuses3 objectForKey:@"sold_list"] valueForKey:@"list"];
for(NSDictionary *news in news_array)
{
@try {
[title_arr addObject:[news valueForKey:@"gtitle"]]; //values Add to title array
}
@catch (NSException *exception) {
[title_arr addObject:[NSString stringWithFormat:@""]];
}
https://stackoverflow.com/questions/5813077
复制相似问题