ObjectiveC特点及特征

Objective-C中的命名前缀说明:

NS:NextStep
CF:Core Foundation
CA:Core Animation
CG:Core Graphics
UI:User Interface

Objective-C与C++的不同之处有:

Objective-C中所有的类都必须继承自NSObject。
Objective-C中所有对象都是指针的形式。
Objective-C用self代替this。
Objective-C使用id代替void*。
Objective-C使用nil表示NULL。
Objective-C只支持单继承。
Objective-C使用YES/NO表示TRUE/FALSE
Objective-C使用#import代替#include
Objective-C中用消息表示类的方法,并采用[aInstance method:argv]调用形式。
Objective-C支持反射机制。
Objective-C支持Dynamic Typing, Dynamic Binding和Dynamic Loading。

Objective-C中的函数声明格式有:

-/+ (return type) function_name;
-/+ (return type) function_name : (parameter type) parameter;
-/+ (return type) function_name :
(parameter type) parameter1 otherParameter :
(parameter_type) parameter2

以上参数说明: – 表示一般函数,+ 表示静态函数。otherParameter是参数的别名(第一个参数的别名省略),在函数调用时方便指定。

IBOutlet,IBAction: 这两个东西其实在语法中没有太大的作用。如果你希望在Interface  Builder中能看到这个控件对象,那么在定义的时候前面加上IBOutlet,在Interface Builder里就能看到这个对象的outlet,如果你希望在 Interface Builder里控制某个对象执行某些动作,就在方法前面加上(IBAction)。

 
原文地址:https://www.cnblogs.com/tuncaysanli/p/2727767.html