我有很多这样命名的按钮:
@property (weak, nonatomic) IBOutlet UIButton *Round1Num1;
@property (weak, nonatomic) IBOutlet UIButton *Round1Num2;
@property (weak, nonatomic) IBOutlet UIButton *Round1Num3;
@property (weak, nonatomic) IBOutlet UIButton *Round1Num4;
@property (weak, nonatomic) IBOutlet UIButton *Round2Num1;
@property (weak, nonatomic) IBOutlet UIButton *Round2Num2;
@property (weak, nonatomic) IBOutlet UIButton *Round2Num3;
@property (weak, nonatomic) IBOutlet UIButton *Round2Num4;
等等。
我想知道是否可以使用stringWithFormat
或类似的方法动态访问它们。
示例(如果代码错误,请见谅!):
而不是self.Round1Num1
我可以打电话self.[NSString stringWithFormat:@"Round%dNum%d", 1, 1]