私は次の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")
アラートを入力しました。値が設定され、Tobyに設定されていますが、Ifステートメントがelse部分だけを実行していません。私が見逃しているのは明らかに単純なことです。
私はObjective-Cを学んでいます