天天看点

Objective-C中的NSObject对象经常使用到的方法

/*

 用于判断对象是不是参数提供的类型(参数可以是父类的class) 

 参数示例: [nsobject class];

 */

- (bool)iskindofclass:(class)aclass;

/* 

 用于判断对象是不是参数提供的类型(参数不可以是父类的class) 

- (bool)ismemberofclass:(class)aclass;

 判断对象是否为指定类的子类

+ (bool)issubclassofclass:(class)aclass;

 用于判断对象是否遵守了参数提供的协议 

 参数示例: @protocol(uiapplicationdelegate)

- (bool)conformstoprotocol:(protocol *)aprotocol;

 用于判断对象是否拥有参数提供的方法 

 参数示例: @selector(test) or @selector(testbyid:)

- (bool)respondstoselector:(sel)aselector;  

 用于判断调用者的实例对象是否拥有提供的方法

+ (bool)instancesrespondtoselector:(sel)aselector;

 延迟调用参数提供的方法,参数所需参数用withobject传入(类似于actionscript3.0中的settimeout函数)

 delay单位:秒

- (void)performselector:(sel)aselector withobject:(id)anargument afterdelay:(nstimeinterval)delay;