- - (id)copy //Returns the object returned by copyWithZone:.调用copyWithZone方法实现复制功能,若是自己的类
//则需要实现copyWithZone方法
- 如:NSString *str2 = [str1 copy];
- + (id)copyWithZone:(struct _NSZone *)zone//copy方法的实现者
- -(id) copyWithZone:(NSZone *)zone
{
Engine * engineCopy;
copyWithZone = [[[self class]allocWithZone:zone]init];
Return(engineCopy)
}
- - (id)mutableCopy//同copy,这里获得的是可变的对象
- 如:NSMutableString * mutableStr1= [str1 mutableCopy];
- + (id)mutableCopyWithZone:(struct _NSZone *)zone//不关注
- + (Class)class//Returns the class object. 返回类对象
- BOOL test = [self isKindOfClass:[SomeClass class]];
- + (Class)superclass//Returns the class object for the receiver’s superclass. 返回父类的类对象
- + (BOOL)isSubclassOfClass:(Class)aClass//判断消息接收者所属的类是不是aClass的子类
- + (BOOL)instancesRespondToSelector:(SEL)aSelector//判断对象能否相应给定的选择器(方法)
- + (BOOL)conformsToProtocol:(Protocol *)aProtocol//判断对象是否实现给定的协议
- ……
- + (NSString *)description//描述
- - (void)performSelector:(SEL)aSelectorwithObject:(id)anArgumentafterDelay:(NSTimeInterval)delay
- Invokes a method of the receiver on the current thread using the default mode after a delay.
- - (BOOL)isKindOfClass:(Class)aClass
- Returns a Boolean value that indicates whether the receiver is an instance of given class or an instance of any class that inherits from that class. (required)
- - (BOOL)isMemberOfClass:(Class)aClass
- Returns a Boolean value that indicates whether the receiver is an instance of a given class. (required)
- 是不是给定类的子类
- - (BOOL)respondsToSelector:(SEL)aSelector
- Returns a Boolean value that indicates whether the receiver implements or inherits a method that can respond to a specified message. (required)
- - (BOOL)conformsToProtocol:(Protocol *)aProtocol
- Returns a Boolean value that indicates whether the receiver conforms to a given protocol. (required)
- - (id)performSelector:(SEL)aSelector
- Sends a specified message to the receiver and returns the result of the message. (required)
- - (id)performSelector:(SEL)aSelector withObject:(id)anObject//同上,object是传入的参数可为nil
- ……
NSObject学习
最新推荐文章于 2024-06-11 22:34:01 发布