Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: @property @synthesize
我什么时候必须使用属性和综合元素作为 NSArray、NSSTring....或 IBOutelt 作为 UIButton 或 UITextFiled?
属性主要用于当其他对象需要更改或访问您对象中的 ivars 时。如果不手动定义 getter 和 setter,或者使用 @property,其他对象无法看到或更改 ivars。属性也经常用于方便内存管理,帮助您防止内存泄漏。