我用下面的編程方式創建了一個帶有兩個UIButton的簡單iPhone屏幕。如何獲取實例變量名?
- (void)viewDidLoad
{
[super viewDidLoad];
UIButton *buttonOne = [UIButton buttonWithType:UIButtonTypeRoundedRect];
buttonOne.frame = CGRectMake(60, 70, 200, 40);
[buttonOne setTitle:@"One" forState:UIControlStateNormal];
[self.view addSubview:buttonOne];
UIButton *buttonTwo = [UIButton buttonWithType:UIButtonTypeRoundedRect];
buttonTwo.frame = CGRectMake(60, 250, 200, 40);
[buttonTwo setTitle:@"Two" forState:UIControlStateNormal];
[self.view addSubview:buttonTwo];
}
現在的按鈕被按下以標題爲「一」,我想要得到的變量名爲「buttonOne」,同樣與標題按鈕被按下「二」我想要得到的變量名「buttonTwo」。
我沒有找到獲取變量名的方法。任何幫助?在此先感謝
你想通過查找變量名稱來做什麼? – Pratik 2013-04-08 12:45:47
你對標準的目標行動設計模式有什麼看法? – 2013-04-08 12:47:23
爲調試目的,因爲宏被用於設置文本,框架等無處不在,所以如果有辦法獲得變量名稱,那麼將有所幫助 – 2013-04-08 12:47:57