- Hands-On Design Patterns with Swift
- Florent Vilmart Giordano Scalzo Sergio De Simone
- 148字
- 2021-07-02 14:45:04
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.
- 同步:秩序如何從混沌中涌現(xiàn)
- Python數(shù)據(jù)分析、挖掘與可視化從入門到精通
- 工業(yè)大數(shù)據(jù)分析算法實戰(zhàn)
- R數(shù)據(jù)科學(xué)實戰(zhàn):工具詳解與案例分析(鮮讀版)
- 達(dá)夢數(shù)據(jù)庫性能優(yōu)化
- 數(shù)據(jù)庫原理與應(yīng)用(Oracle版)
- INSTANT Apple iBooks How-to
- SQL Server 2012數(shù)據(jù)庫管理教程
- Mastering LOB Development for Silverlight 5:A Case Study in Action
- 貫通SQL Server 2008數(shù)據(jù)庫系統(tǒng)開發(fā)
- 改變未來的九大算法
- Python數(shù)據(jù)分析從小白到專家
- 算力經(jīng)濟(jì):從超級計算到云計算
- Artificial Intelligence for Big Data
- MySQL核心技術(shù)手冊