自学ios:second day Objective-C

2023-05-21,,

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;

《自学ios:second day Objective-C.doc》

下载本文的Word格式文档,以方便收藏与打印。