这是整个代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"DetailCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2
reuseIdentifier:CellIdentifier];
NSUInteger sectionIndex = [indexPath section];
NSUInteger rowIndex = [indexPath row];
NSDictionary *section = [self.sections objectAtIndex:sectionIndex];
NSArray *rows = [section objectForKey:@"rows"];
NSDictionary *row = [rows objectAtIndex:rowIndex];
cell.textLabel.text = [row objectForKey:@"label"];
cell.detailTextLabel.text = [[self.myManagedObject valueForKey:[row objectForKey:@"key"]] description];
return cell;
}
我的问题是:
cell.textLabel.text = [row objectForKey:@"label"];
cell.detailTextLabel.text = [[self.myManagedObject valueForKey:[row objectForKey:@"key"]] description]; //This is NSDate
- 为什么这段代码使用两种不同的格式:objectForKey 和 valueForKey?
- 为什么不需要使用 objectForKey 调用 self.myManagedObject?
- 描述的目的是什么?