我目前正在编写一个应用程序,该应用程序旨在利用从后端引入的数据进行扩展。为了测试这种可扩展性,我目前正在使用 plist 来引入一些基本数据。
计划最终让男性/女性图标出现在用户名旁边以用于性别/视觉目的(目前使用颜色),但是,在正确的 tableView 方法中编写条件语句后,应用程序似乎完全跳过了这些参数。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
SelectProfileCell *cell = (SelectProfileCell *) [tableView dequeueReusableCellWithIdentifier:@"SelectProfileCell"];
NSArray *array = [[NSArray alloc] initWithArray:[userArray objectAtIndex:indexPath.row]];
cell.nameLabel.text = [array objectAtIndex:0];
gender = [array objectAtIndex:1];
if(gender == @"Male"){
cell.genderLogo.backgroundColor = [UIColor blueColor];
NSLog(@"Male");
}
if(gender == @"Female"){
cell.genderLogo.backgroundColor = [UIColor greenColor];
NSLog(@"Female");
}
return cell;
}
在这种情况下, userArray 和 gender 都是已经初始化的实例变量。“userArray”已经从属性列表中传递了适当的二维数组数据(使用控制台检查)。
同样,日志没有显示“男性”/“女性”调试消息,因此这些“if”语句由于某种原因被跳过。有什么建议么?
谢谢!