If statement does not work properly

前端 未结 3 584
不知归路
不知归路 2021-01-29 15:23

This is my code:

NSString * atime = [NSString stringWithFormat:@\"%@\",[theDataObject.minuteArray objectAtIndex:indexPath.row]];

NSLog(@\"value of atime is:%@\"         


        
3条回答
  •  灰色年华
    2021-01-29 16:05

    if (atime==@"0")
    

    Compares the memory address of atime with the address of constant string @"0".

    if ([atime isEqualToString:@"0"]) 
    

    Compares the values that are stored in the two memory locations.

    From your requirement it is seen that you want to compare the value not the memory location. So go for 2nd one.

提交回复
热议问题