美文网首页
NSObject.h

NSObject.h

作者: ShenYj | 来源:发表于2016-09-04 20:59 被阅读145次
    
    
    
    
    @protocol NSCopying
    
    - (id)copyWithZone:(NSZone *)zone;
    
    @end
    
    @protocol NSMutableCopying
    
    - (id)mutableCopyWithZone:(NSZone *)zone;
    
    @end
    
    #pragma mark - 归档协议
    @protocol NSCoding
    
    - (void)encodeWithCoder:(NSCoder *)aCoder;  // 归档
    - (id)initWithCoder:(NSCoder *)aDecoder;    // 解挡
    
    @end
    
    
    @protocol NSSecureCoding <NSCoding>
    
    @required
    
    + (BOOL)supportsSecureCoding;
    
    @end
    
    #prama mark - 基类
    @interface NSObject (NSCoderMethods)
    
    + (NSInteger)version;
    + (void)setVersion:(NSInteger)aVersion;
    - (Class)classForCoder;
    - (id)replacementObjectForCoder:(NSCoder *)aCoder;
    - (id)awakeAfterUsingCoder:(NSCoder *)aDecoder NS_REPLACES_RECEIVER;
    
    @end
    
    
    /***********    Discardable Content     ***********/
    
    @protocol NSDiscardableContent
    @required
    - (BOOL)beginContentAccess;
    - (void)endContentAccess;
    - (void)discardContentIfPossible;
    - (BOOL)isContentDiscarded;
    @end
    
    @interface NSObject (NSDiscardableContentProxy)
    - (id)autoContentAccessingProxy NS_AVAILABLE(10_6, 4_0);
    @end
    
    
    /***********    Object Allocation / Deallocation        *******/
        
    FOUNDATION_EXPORT id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
    
    FOUNDATION_EXPORT void NSDeallocateObject(id object) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
    
    FOUNDATION_EXPORT id NSCopyObject(id object, NSUInteger extraBytes, NSZone *zone) NS_AUTOMATED_REFCOUNT_UNAVAILABLE NS_DEPRECATED(10_0, 10_8, 2_0, 6_0);
    
    FOUNDATION_EXPORT BOOL NSShouldRetainWithZone(id anObject, NSZone *requestedZone) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
    
    FOUNDATION_EXPORT void NSIncrementExtraRefCount(id object) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
    
    FOUNDATION_EXPORT BOOL NSDecrementExtraRefCountWasZero(id object) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
    
    FOUNDATION_EXPORT NSUInteger NSExtraRefCount(id object) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
    
    #if __has_feature(objc_arc)
    
    // After using a CFBridgingRetain on an NSObject, the caller must take responsibility for calling CFRelease at an appropriate time.
    NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) {
        return (__bridge_retained CFTypeRef)X;
    }
    
    NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) {
        return (__bridge_transfer id)X;
    }
    
    #else
    
    // This function is intended for use while converting to ARC mode only.
    NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) {
        return X ? CFRetain((CFTypeRef)X) : NULL;
    }
    
    // This function is intended for use while converting to ARC mode only.
    NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) {
        return [(id)CFMakeCollectable(X) autorelease];
    }
    
    #endif
    
    #pragma mark - 模拟器自带头文件
    
    @class NSString, NSMethodSignature, NSInvocation;
    
    @protocol NSObject
    
    - (BOOL)isEqual:(id)object;                     // 判断两个对象是否相等
    - (NSUInteger)hash;
    
    - (Class)superclass;                            // 返回对象的父类
    - (Class)class;                                 // 返回对象的类型
    - (id)self;
    - (struct _NSZone *)zone OBJC_ARC_UNAVAILABLE;
    
    - (id)performSelector:(SEL)aSelector;           // 向对象发送aSelector消息
    - (id)performSelector:(SEL)aSelector withObject:(id)object; // 向对象发送aSelector消息,并带有该消息需要的一个参数
    // 向对象发送aSelector消息,并带有该消息需要的两个参数
    - (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2;
    
    - (BOOL)isProxy;                                // 判断是否是代理
    
    - (BOOL)isKindOfClass:(Class)aClass;            // 是否是某个类(包括子类)
    - (BOOL)isMemberOfClass:(Class)aClass;          // 是否是某个类(不包括子类)
    
    - (BOOL)conformsToProtocol:(Protocol *)aProtocol;   // 判断是否遵守aProtocol协议
    - (BOOL)respondsToSelector:(SEL)aSelector;          // 判断是否实现了aSelector方法
    
    #pragma - mark MRC
    - (id)retain OBJC_ARC_UNAVAILABLE;
    - (oneway void)release OBJC_ARC_UNAVAILABLE;
    - (id)autorelease OBJC_ARC_UNAVAILABLE;
    - (NSUInteger)retainCount OBJC_ARC_UNAVAILABLE;
    
    - (NSString *)description;
    
    @optional
    - (NSString *)debugDescription;
    
    @end
    
    
    __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0)
    OBJC_ROOT_CLASS
    OBJC_EXPORT
    @interface NSObject <NSObject> {
        Class isa  OBJC_ISA_AVAILABILITY;
    }
    
    + (void)load;
    
    + (void)initialize;     // 初始化, 类加载的时候执行,只执行一次
    - (id)init;             // 初始化
    
    + (id)new;
    + (id)allocWithZone:(struct _NSZone *)zone;
    + (id)alloc;
    - (void)dealloc;
    
    - (void)finalize;
    
    - (id)copy;
    - (id)mutableCopy;
    
    + (id)copyWithZone:(struct _NSZone *)zone OBJC_ARC_UNAVAILABLE;
    + (id)mutableCopyWithZone:(struct _NSZone *)zone OBJC_ARC_UNAVAILABLE;
    
    + (Class)superclass;                                    // 返回父类类型
    + (Class)class;                                         // 返回类型
    + (BOOL)instancesRespondToSelector:(SEL)aSelector;      // 实例对象是否实现方法
    + (BOOL)conformsToProtocol:(Protocol *)protocol;        // 是否遵守协议
    
    - (IMP)methodForSelector:(SEL)aSelector;                // 返回一个从aSelector创建的方法的实现
    + (IMP)instanceMethodForSelector:(SEL)aSelector;
    
    - (void)doesNotRecognizeSelector:(SEL)aSelector;
    
    - (id)forwardingTargetForSelector:(SEL)aSelector __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
    - (void)forwardInvocation:(NSInvocation *)anInvocation;
    - (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector;
    
    + (NSMethodSignature *)instanceMethodSignatureForSelector:(SEL)aSelector;
    
    - (BOOL)allowsWeakReference UNAVAILABLE_ATTRIBUTE;
    - (BOOL)retainWeakReference UNAVAILABLE_ATTRIBUTE;
    
    + (NSString *)description;
    
    + (BOOL)isSubclassOfClass:(Class)aClass;  // 是否是某个类的子类
    
    + (BOOL)resolveClassMethod:(SEL)sel __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
    + (BOOL)resolveInstanceMethod:(SEL)sel __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0);
    
    @end
    
    
    

    相关文章

      网友评论

          本文标题:NSObject.h

          本文链接:https://www.haomeiwen.com/subject/tcalettx.html