我昨天刚开始学习Objective-C,我不太明白这个警告:
Property access result unused - getters should not be used for side effects
使用此代码(第 3 行给出警告,self.addItem()):
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
if (textField == self.itemTxt) {
self.addItem;
self.itemTxt.text = @"";
}
return YES;
}
- (IBAction)addItem {
[self.model addItemToArray: _itemTxt.text];
_itemTxt.text = @"";
}
为什么我会收到此警告?