0
嘿大家,所以我有這樣的代碼,我想優化它的iOS的Xcode變量
,而不是到處都這樣做,我想將它添加在了,但是我不知道如何將它添加
_p1.userInteractionEnabled = YES;
_p2.userInteractionEnabled = YES;
_p3.userInteractionEnabled = YES;
_p4.userInteractionEnabled = YES;
_p5.userInteractionEnabled = YES;
_p6.userInteractionEnabled = YES;
_p7.userInteractionEnabled = YES;
_p8.userInteractionEnabled = YES;
_p9.userInteractionEnabled = YES;
而不是此長碼我想將它添加一個用於將這個樣子
for (int i = 1; i <= 10; i++)
{
_p[i].userInteractionEnabled = YES;
}
也許'IBOutletCollection'是你想要的。它在很多地方都有描述,例如http://nshipster.com/ibaction-iboutlet-iboutletcollection/ – Mats