- 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.
推薦閱讀
- 大數(shù)據(jù)技術(shù)基礎(chǔ)
- Python數(shù)據(jù)分析入門:從數(shù)據(jù)獲取到可視化
- Learn Unity ML-Agents:Fundamentals of Unity Machine Learning
- Spark核心技術(shù)與高級(jí)應(yīng)用
- 數(shù)據(jù)驅(qū)動(dòng)設(shè)計(jì):A/B測(cè)試提升用戶體驗(yàn)
- 大數(shù)據(jù)架構(gòu)和算法實(shí)現(xiàn)之路:電商系統(tǒng)的技術(shù)實(shí)戰(zhàn)
- Spark大數(shù)據(jù)編程實(shí)用教程
- 利用Python進(jìn)行數(shù)據(jù)分析(原書(shū)第2版)
- 云工作時(shí)代:科技進(jìn)化必將帶來(lái)的新工作方式
- 大數(shù)據(jù)隱私保護(hù)技術(shù)與治理機(jī)制研究
- 數(shù)據(jù)之美:一本書(shū)學(xué)會(huì)可視化設(shè)計(jì)
- 數(shù)字化轉(zhuǎn)型實(shí)踐:構(gòu)建云原生大數(shù)據(jù)平臺(tái)
- Learning Ansible
- 數(shù)據(jù)庫(kù)技術(shù)與應(yīng)用:SQL Server 2008
- 2D 計(jì)算機(jī)視覺(jué):原理、算法及應(yīng)用