基本沒用過 Object-C
先來篇文檔了解概念 http://www.cocoachina.com/b/?p=122
函數聲明:
- (傳回值類型) 函數名 : (類型)參數1 (類型)參數2
函數調用:
[self 函數名: 參數]
字元串前面要加 @
對象
聲明 class
@infterface
@end
實作
@implementation
@end
簡單解釋
Java 的 GC 是 Runtime執行的
而 ARC 是 complile time 執行的
就是說編譯的時候,自動插入/添加 the release, retain, autorelease 這些語句
GC 對于 ARC的好處
自動收集 retain cycles
指派不不要額外的語句(比如轉移 ownership)
ARC對于 GC 的好處
記憶體占用标尺小(對象釋放快)
GC線程要吃 CPU資源,讓app暫時,而ARC沒有這種事
http://www.oschina.net/translate/objc-automatic-reference-counting-in-xcode-explained
http://en.wikipedia.org/wiki/Automatic_Reference_Counting
http://stackoverflow.com/questions/7874342/what-is-the-difference-between-objective-c-automatic-reference-counting-and-garb