- 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.
- 公有云容器化指南:騰訊云TKE實戰與應用
- SQL Server 2012數據庫技術與應用(微課版)
- Test-Driven Development with Mockito
- 文本數據挖掘:基于R語言
- 數據革命:大數據價值實現方法、技術與案例
- 跟老男孩學Linux運維:MySQL入門與提高實踐
- Hadoop大數據開發案例教程與項目實戰(在線實驗+在線自測)
- Splunk智能運維實戰
- 跨領域信息交換方法與技術(第二版)
- 大數據隱私保護技術與治理機制研究
- 推薦系統全鏈路設計:原理解讀與業務實踐
- Access 2010數據庫應用技術教程(第二版)
- 社交網站的數據挖掘與分析(原書第2版)
- Access數據庫實用教程習題與實驗指導(第2版)
- 數據要素化時代的數據治理