我有以下 Objective-c 函数
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSUInteger section = [indexPath section];
NSUInteger row = [indexPath row];
NSString *key = [keys objectAtIndex:section];
NSArray *nameSection = [mysearchdata objectForKey:key];
static NSString *SectionsTableID = @"SectionsTableID";
static NSString *TobyCellID = @"TobyCellID";
NSString *aName = [nameSection objectAtIndex:row];
if (aName == @"Toby")
{
TobyCell *cell = [tableView dequeueReusableCellWithIdentifier:TobyCellID];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"TobyCell" owner:self options:nil];
for (id oneObject in nib)
if ([oneObject isKindOfClass:[TobyCell class]])
cell = (TobyCell *)oneObject;
}
cell.lblName.text = [nameSection objectAtIndex:row];
return cell;
}
else
{
//standard cell loading code
}
}
我想要的只是当行等于我的名字时触发 if 语句 - 非常令人兴奋。
if (aName == @"Toby")
我已经发出警报,并且正在设置 Value 并将其设置为 Toby 但 If 语句不只是执行 else 部分。显然,我缺少一些简单的东西。
我正在学习 Objective-C