【发布时间】:2011-01-07 18:25:23
【问题描述】:
我在理解属性时遇到了问题。 如果我希望属性不被其访问者修改(通过复制返回)并通过引用设置(保留),我应该编写什么样的属性。
例子:
MyType* theAttribute = MyObject.attribute;
[theAttribute changeSomething]; // Does not have to change the MyObject attribute, working with a copy return
MyType tmpObject = [[MyType alloc] init];
MyObject.attribute = tmpObject; // Want a retain here
[tmpObject release];
【问题讨论】:
标签: objective-c properties copy retain