close
  • objective-c 檔案分類
.h 標頭檔
.m

實現檔

  • 關於.m:

大致分成兩個區塊:

@interface{

}

...

@end

@implementation

...

@end

  • @interface區塊:宣告變數,宣告方法method。
  • @implementation區塊:實現方法的區塊。

 

  • 宣告類型

靜態類型:Static typing 

NSString *myName;

動態類型:Dynamic typing

id myName;

這兩者差異在於,NSString有指定類別型態,id則是直接指定為變數為指標。

  • 方法宣告 e.g. - (void)insertObject:(id) anObject

宣告實例方法,用(-)號

宣告類方法,用(+)號

  • 消息表達式??

用 “ [ ” “ ] ” 表示 e.g. [myName insertObject:anObject atIndex:0]

  • 用點記法給定屬性值

self.text = label;

  • 宣告物件的屬性與存取方法

@property (copy,nonatomic) NSString *userName;

  • @synthesize enabled = _isEnabled; ???? 
  • self super
arrow
arrow
    文章標籤
    implementation
    全站熱搜

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