gpt4 book ai didi

iphone - json 对象 UITableView

转载 作者:行者123 更新时间:2023-11-28 23:08:05 25 4
gpt4 key购买 nike

服务器返回如下所示的json对象:大约51个对象

[{"location":"Location1","email":"sriharsha@yahoo.com","phone":"123456"},{"location":"Location2","email":"sriharsha.mandya@gmail.com","phone":"123456789"},
.
.
..
..
..51]

我想将这个值首先分配给带有电子邮件和电话号码的位置和详细 View ......

我使用的代码如下:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];

NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];

NSDictionary *dictionary = [responseString JSONValue];
NSArray *response = [dictionary objectForKey:@"location"];

exercises = [[NSArray alloc] initWithArray:response];
[table reloadData];
}

我哪里错了请指教...

最佳答案

乍一看,响应字符串看起来像一个字典数组

访问数据尝试类似的东西

NSArray* arrayOfDictionaries = [responseString JSONValue];
NSDictionary* firstDictionary = [arrayOfDictionaries objectAtIndex:0];

关于iphone - json 对象 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8897664/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com