简体   繁体   中英

iOS 5: Executing if statements inside of a UITableView delegate method

I'm currently writing an application that's meant to scale with data brought in from the back-end. To test this scalability, I'm currently using plists to bring in some basic data.

The plan is to eventually have male/female icons appear next to the user names for gender/visual purposes (using colors currently), however, after writing a conditional statement in the proper tableView method, the application seems to skip those arguments entirely.

- (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;
}

In this instance, both userArray and gender are instance variables that have already been initialized. "userArray" has already been passed the appropriate 2D Array data from the property list (used the console to check this).

Again, the log is not showing the "Male"/"Female" debug messages, so these "if" statements are being skipped for some reason. Any suggestions?

Thank you!

使用[gender isEqualToString:@"Male"]代替==

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM