NSObject学习
2015-06-15 20:52
666 查看
- (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
……
//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
……
相关文章推荐
- Objective-c 创建类的使用
- Java-Object的clone方法 protected的相关问题。
- [Object-C]iOS 形参个数可变的方法
- objective-c的成员变量:坑爹的苹果不断更新版本使得代码变化也大。
- Objective-C 关于锁的种类
- swift 和 Objective-C 互相调用
- Programming with Objective-C 学习笔记
- iPhone/iOS中保存自定义对象(Custom Object/Custom Class)的数组(NSMutableArray/NSArray)到NSUserDefaults
- object-C与JAVA和C++对比
- Objective-C Method Swizzling 的最佳实践
- JSONObject与JSONArray的使用
- objective c 类目 延展 协议
- Objective-C类成员变量深度剖析
- Objective-C Method Swizzling 的最佳实践
- 学习笔记(objective-c)-类别(category)
- 学习笔记(objective-c)-重写isEqual方法
- objective-c 键值监听
- iOS开发--Objective-C之KVC
- Objective-C 知识点总结
- Objective-C面试题2