Ios 如何在表格单元格中加载?下面是json数据

Ios 如何在表格单元格中加载?下面是json数据,ios,json,swift,uitableview,Ios,Json,Swift,Uitableview,我有这些类型的json数据,如何在表格单元格中加载,加载firstname和lastname的键值是多少 [{ "firstName": "John", "lastName": "Doe" }, { "firstName": "Anna", "lastName": "Smith" }, { "firstName": "Peter", "lastName": "Jones" }] 相应地更改您的UITableViewCellStyle,或者为它们创

我有这些类型的json数据,如何在表格单元格中加载,加载firstname和lastname的键值是多少

[{
    "firstName": "John",
    "lastName": "Doe"
}, {
    "firstName": "Anna",
    "lastName": "Smith"
}, {
    "firstName": "Peter",
    "lastName": "Jones"
}]
相应地更改您的
UITableViewCellStyle
,或者为它们创建自己的标签。

Swift版本

@property (nonatomic, strong) NSArray *responseArray;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // get JSON response from server or local to NSArray
    _responseArray = [NSJSONSerialization JSONObjectWithData:yourJsonHere options:0 error:nil];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cellIdentifier"];

    NSDictionary *row = _responseArray[indexPath.row];
    [cell.textLabel setText:row[@"firstName"]];
    [cell.detailTextLabel setText:row[@"lastName"]];
    return cell;
}

是[0][“firstName”]?您能展示一些您迄今为止尝试过的代码吗?原始问题中没有显示代码(因此被否决),但问题包含
swift
标记。我觉得这不像斯威夫特。我不在乎,我会尽我所能帮助那个家伙。如果他知道答案或者认识一个开发者,他就不会在这里了。我的回答总比没有好。。
 //create a struct to represent your data
 struct People {
     var firstName: String!
     var lastName: String!
 }

 //create an array to store your data in your class
 var peopleArray: [People]?

 //when the view loads, take the data you receive and parse it
 for person in dataReceived {
     let personToAdd = People(firstName: person["firstName"], lastName: person["lastName"]
     peopleArray.append(personToAdd)
 }

 //cell for row at index path
 let cell = tableView.dequeueReusableCellWithIdentifier("identifier")
 let personForCell = peopleArray[indexPath.row]
 cell.textLabel!.text = personForCell.firstName
 cell.detailTextLabel.text = personForCell.lastName