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

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.

主站蜘蛛池模板: 宣恩县| 平乐县| 香河县| 景洪市| 汶川县| 增城市| 卫辉市| 玛多县| 大宁县| 定南县| 偃师市| 桂阳县| 西畴县| 习水县| 霍林郭勒市| 乡城县| 商水县| 辽宁省| 兴海县| 邵东县| 墨玉县| 布尔津县| 海兴县| 黄石市| 通河县| 兴城市| 鄯善县| 新密市| 竹山县| 潜山县| 新邵县| 东安县| 九龙坡区| 出国| 宣恩县| 龙山县| 达日县| 永平县| 隆安县| 大化| 浦江县|