假设我们在 Objective-C 类中有一个属性。并且我们在实现文件中综合了它。这样就生成了setter和getter。我们可以通过编写 self.variable
或 [self variable]
来调用属性的 getter。我们也可以这样调用setter
[self.variable setVariable: value];
但是如果我们写 self.variable = value;
在这种情况下调用的是 setter 还是其他东西例如 operator = function
。
谢谢;
最佳答案
在
的情况下self.variable = value;
[self setVariable:value]
被调用。
关于ios - 在 Objective-C 中调用 setter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25488057/