oc 是 c 的超集,從c擴展而來,具備面向對象的特性,比如類,消息,單繼承。
c的部分:
數據類型:
short,int,long,float,double,char,pointer,struct
常用方法:
readline()
atoi()
sizeof()
malloc()
oc的部分:
receiver:classNameOrObject
selector:method
消息的傳遞通過[receiver selector]實現,
eg:NSDate *now = [NSDate date];
-:instance method, 實體方法,依賴於一個類的一個實例;
+:class method, 類方法,類似於java的靜態方法。
instance variable start with an understore:such as _name。
多參數方法調用:
[receiver selector:argOneVal argTwoName:argTwoVal argThreeName:argThreeVal ...]
id:相當於 NSObject * ,已經包含了*號,所以id類型的變量前面沒有*號,eg:id delegate;