- Hands-On Design Patterns with Swift
- Florent Vilmart Giordano Scalzo Sergio De Simone
- 124字
- 2021-07-02 14:45:04
Using and misusing manual reference counting
Now, let's take a look at how we can use and abuse those mechanics, and the kinds of errors that we can litter our code with when using manual reference counting:
- (void) doSomething {
NSString *aString = [[NSString alloc] init];
// calling alloc returns an object with a retain count of 1
// do something with the string
// We're done with the string, call release
[aString release];
}
The preceding is a very simplistic example; many times, you'll pass your objects around, and will need to keep track of when to retain or release your objects. Let's go over some of the issues that you can encounter if you're not careful with your retain and release calls.
推薦閱讀
- GitHub Essentials
- Mastering Ninject for Dependency Injection
- Game Development with Swift
- 文本挖掘:基于R語言的整潔工具
- Creating Dynamic UIs with Android Fragments(Second Edition)
- Dependency Injection with AngularJS
- 大話Oracle Grid:云時代的RAC
- OracleDBA實戰攻略:運維管理、診斷優化、高可用與最佳實踐
- Lego Mindstorms EV3 Essentials
- 云原生數據中臺:架構、方法論與實踐
- 信息學競賽寶典:數據結構基礎
- Hadoop集群與安全
- 聯動Oracle:設計思想、架構實現與AWR報告
- MySQL數據庫實用教程
- Rust High Performance