0
我有一个iPad应用程序,我有一个对象具有布尔类型的五个属性。我有一个UIImageView,我必须将图像放入取决于哪些属性为真。这是我的源代码工作正常:Objective-C - 布尔属性 - >映射图像
if (myObject.attribute1) {
myCell.imageView.image = [UIImage imageNamed:@"imageForAttribute1.png"];
} else if (myObject.attribute2) {
myCell.imageView.image = [UIImage imageNamed:@"imageForAttribute2.png"];
} else if (myObject.attribute3) {
myCell.imageView.image = [UIImage imageNamed:@"imageForAttribute3.png"];
} else if (myObject.attribute4) {
myCell.imageView.image = [UIImage imageNamed:@"imageForAttribute4.png"];
} else if (myObject.attribute5) {
myCell.imageView.image = [UIImage imageNamed:@"imageForAttribute5.png"];
}
对于我来说,它看起来不那么好看。没有更好的方法来解决这个“问题”吗?
最好的问候,蒂姆。