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

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.

主站蜘蛛池模板: 萍乡市| 偃师市| 三河市| 拉萨市| 罗江县| 荣成市| 龙泉市| 灵丘县| 平塘县| 贡山| 砚山县| 凤台县| 西和县| 宾川县| 伊金霍洛旗| 屏东市| 长寿区| 周至县| 赤水市| 乌拉特前旗| 万山特区| 武清区| 邹平县| 离岛区| 永川市| 永年县| 肇源县| 蓬溪县| 武宣县| 高州市| 雷州市| 祁东县| 凌云县| 桂林市| 遂川县| 武安市| 凤冈县| 枝江市| 邳州市| 南汇区| 临夏市|