• Objective-C識別字皆前置@字符
  • id是指標,可以指向任何物件
  • BOOL其實是char,用YES代表1,NO代表0
  • IBOutlet是給Interface Builder看的,沒別的意思
  • IBAction是給Interface Builder看的,與void是同樣的東西
  • nil和NULL是同樣的東西,一般將nil用於物件指標
  • 送給nil的任何通知都會被忽略
  • 不能把nil放進NSArray,要用[NSNull null]代替
  • 儲存在nib檔的物件被重新賦予生命之後,每個物件都會收到awakeFromNib通知
  • #import類似#include,#import會確保檔案只被引入一次
  • 把數字當物件傳遞時可以用[[NSNumber alloc] initWithInt:(1234)]
  • 用alloc建立物件時,retain count為1,呼叫retain會將retain count加1,呼叫release會將retain count減1,retain count為0時,物件會被釋放
  • 物件的dealloc會在retain count為0時被呼叫
  • 呼叫autorelease會將物件放進autorelease pool,在event loop結束時被釋放
  • 從alloc、new、copy或mutableCopy取得的物件,retain count為1,且不在autorelease pool中
  • 從其它函式取得的物件,retain count為1,且在autorelease pool中,要呼叫retain才能保留物件下次再用,否則會在event loop結束時被釋放
  • init中要記得先[super init],dealloc中要記得在最後[super dealloc]
  • NSLog(@"%@")顯示的物件資訊是由(NSString*)description提供
  • 用NSWindow的initialFirstResponder指定預設輸入焦點
  • 編譯取取得selector:SEL selector = @selector(message:)
  • 程式執行時從字串取得selector:SEL selector = NSSelectorFromString(@"message:")
  • [object message:arg]會被編譯器換成objc_msgSend(object, @selector(message:), arg)
  • 可以用(BOOL)respondsToSelector:(SEL)aSelector檢查物件的method是否存在
文章標籤
全站熱搜
創作者介紹
創作者 Forth 的頭像
Forth

不就是個blog

Forth 發表在 痞客邦 留言(0) 人氣(52)