我有一个从网站下载 JSON 文件并将其显示在表格视图中的代码。我的下一步是在详细列表中显示标题(人名)。
我怎样才能做到这一点?我无法进入主屏幕上显示的数据。
这是在第一个屏幕上显示名称的代码。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath
(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"BasicCell";
UITableViewCell *myCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
// Get the location to be shown
Location *item = _feedItems[indexPath.row];
// Get references to labels of cell
myCell.textLabel.text = item.Name;
return myCell;
}
--- 开始编辑-----
我在 HomeModel.M 类中有一个 NSDictionary。
for (int i = 0; i < jsonArray.count; i++)
{
NSDictionary *jsonElement = jsonArray[i];
// Create a new location object and set its props to JsonElement properties
Location *newLocation = [[Location alloc] init];
newLocation.Name = jsonElement[@"Email"];
newLocation.list = jsonElement[@"lijst"];
newLocation.Password = jsonElement[@"Password"];
// Add this question to the locations array
[_locations addObject:newLocation];
}
// Ready to notify delegate that data is ready and pass back items
if (self.delegate)
{
[self.delegate itemsDownloaded:_locations];
}
--- 结束编辑----
所以基本上我想要的是在 ToGetList 类中显示相同的名称......
像这样的东西:
- (void)viewDidLoad
{
[super viewDidLoad];
self.nameLabel.text = item.Name //Reference to the ViewController.m class;
// Do any additional setup after loading the view.
}