官术网_书友最值得收藏!

Copying

Copying an object doesn't increase its reference count, and ownership can be safely passed from one object to the other. The object's copy will have a reference count of one just after the copying process, no matter what the original object's reference count was.

The text property of UILabel is marked as copy, so any NSString * passed as the text property can be safely deallocated. If the text property of UILabel was assign, the string would need to be retained by an external object. If it was retain, this would probably unnecessarily extend object lifetimes.

In Swift, String is a struct that benefits the value type memory behaviors, and it is always copied. It is still possible to disable ARC with Objective-C 2.0, so let's use this modern variant, as it is still very popular in many code bases.

主站蜘蛛池模板: 霍州市| 武安市| 云安县| 焦作市| 乐亭县| 修水县| 湖北省| 南江县| 黄龙县| 宁晋县| 方正县| 济阳县| 普陀区| 根河市| 保定市| 屏东市| 称多县| 庆阳市| 阿瓦提县| 柘荣县| 栾川县| 溧阳市| 科尔| 黄大仙区| 安顺市| 始兴县| 奈曼旗| 襄垣县| 革吉县| 饶平县| 连江县| 宣威市| 临海市| 台南市| 太和县| 玛纳斯县| 东乡县| 三亚市| 通化市| 平度市| 陆川县|