2012年7月28日 星期六

ARC - Automatic Reference Counting 介紹

初探ARC - Automatic Reference Counting




截錄部份重點


在iOS5首次提出了ARC(Automatic Reference Counting)這個解決方案
試圖讓開發者減少寫Reference Counting的時候產生的錯誤。

ARC有哪些重點?
1. 它是Compile-time的技術,並不是runtime有一個thread去幫你處理reference count..
2. 開發者不能再直接使用retain, release, autorelease,改由compiler幫你塞這些code
3. 所有的property不再使用retain, assign而改用strong, weak取代
4. NSAutoreleasePool也要改用特有的 @autoreleasepool{ } 來取代



在ARC當中,如果weak pointer所指到的object的retain count已經是0的時候
則這個weak pointer也會被設成0
這就是所謂的"zeroing weak reference"





如何使用Reference Counting機制
如何開關Rederence Counting的功能.

沒有留言:

張貼留言