0
我想要将图像的名称分配给按钮。图像名称存储在一个数组中。不过我正在错误的标题Swift - 不能用索引类型为NSNumber的值类型[String]下标吗?
我的代码:
//profilePic is the button
//friend is a coredata object received from another view. picIndex is stored as int16 in the coredata
profilePic.setImage(UIImage(named: imgArray[friend.picIndex]), forState: UIControlState.Normal);
我的数组:
var imgArray = ["a.jpg", "aq3d.jpg", "b.jpg", "c.jpg", "d.jpg", "e.jpg", "f.jpg",
"fallout.jpg", "g.jpg", "h.jpg", "i.jpg", "j.jpg", "k.jpg", "overwatch.jpg", "space.jpg"];
OT:你鸵鸟政策需要','在斯威夫特。 –
'friend.picIndex'是一个'NSNumber'吗? – rmaddy
@RashwanL是的,我知道。但是我想继续使用它,因为我也会使用其他语言。它的习惯 –