我试图实现下面的代码但没有成功。基本上,我想将显示名称设置为使用 thisPhoto.userFullName
(如果它不是“空白”),否则显示 thisPhoto.userName
。
UILabel *thisUserNameLabel = (UILabel *)[cell.contentView viewWithTag:kUserNameValueTag];
NSLog(@"user full name %@",thisPhoto.userFullName);
NSLog(@"user name %@",thisPhoto.userName);
if (thisPhoto.userFullName && ![thisPhoto.userFullName isEqual:[NSNull null]] )
{
thisUserNameLabel.text = [NSString stringWithFormat:@"%@",thisPhoto.userFullName];
}
else if (thisPhoto.userFullName == @"")
{
thisUserNameLabel.text = [NSString stringWithFormat:@"%@",thisPhoto.userName];
}
目前,即使userFullName
为空,我的userName
仍然没有显示在屏幕上。
最佳答案
我更愿意
if([thisPhoto.userFullName length])
关于objective-c - 检查对象实例的属性是否为 'blank',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6219617/