今天寫了下面的快速枚舉for循環代碼,從按鈕數組subButtons中取出button,然后修改button的樣式,在添加到view中
for (UIButton *button in subButtons) { button.selected = YES; button = [self updateStatusWithButton:button]; [self.view addSubview:button]; }
但是寫完還未編譯,就報如下錯誤:
Fast enumeration variables cannot be modified in ARC by default; declare the variable __strong to allow this
即: 快速枚舉變量在ARC下默認不能修改其引用屬性,聲明變量為__strong允許修改
所以修改如下即可:
for (__strong UIButton *button in subButtons) { button.selected = YES; button = [self updateButtonStatusWithButton:button isInitial:YES]; [self.view addSubview:button]; }