`

NSObject.h

 
阅读更多
/*	NSObject.h
	Copyright (c) 1994-2009, Apple Inc. All rights reserved.
*/

#import <Foundation/NSObjCRuntime.h>
#import <Foundation/NSZone.h>

@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
@class Protocol;

/***************	Basic protocols		***************/

@protocol NSObject

- (BOOL)isEqual:(id)object;
- (NSUInteger)hash;

- (Class)superclass;
- (Class)class;
- (id)self;
- (NSZone *)zone;

- (id)performSelector:(SEL)aSelector;
- (id)performSelector:(SEL)aSelector withObject:(id)object;
- (id)performSelector:(SEL)aSelector withObject:(id)object1 withObject:(id)object2;

- (BOOL)isProxy;

- (BOOL)isKindOfClass:(Class)aClass;
- (BOOL)isMemberOfClass:(Class)aClass;
- (BOOL)conformsToProtocol:(Protocol *)aProtocol;

- (BOOL)respondsToSelector:(SEL)aSelector;

- (id)retain;
- (oneway void)release;
- (id)autorelease;
- (NSUInteger)retainCount;

- (NSString *)description;

@end

@protocol NSCopying

- (id)copyWithZone:(NSZone *)zone;

@end

@protocol NSMutableCopying

- (id)mutableCopyWithZone:(NSZone *)zone;

@end

@protocol NSCoding

- (void)encodeWithCoder:(NSCoder *)aCoder;
- (id)initWithCoder:(NSCoder *)aDecoder;

@end

/***********	Base class		***********/

@interface NSObject <NSObject> {
    Class	isa;
}

+ (void)load;

+ (void)initialize;
- (id)init;

+ (id)new;
+ (id)allocWithZone:(NSZone *)zone;
+ (id)alloc;
- (void)dealloc;

- (void)finalize AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;

- (id)copy;
- (id)mutableCopy;

+ (id)copyWithZone:(NSZone *)zone;
+ (id)mutableCopyWithZone:(NSZone *)zone;

+ (Class)superclass;
+ (Class)class;
+ (BOOL)instancesRespondToSelector:(SEL)aSelector;
+ (BOOL)conformsToProtocol:(Protocol *)protocol;
- (IMP)methodForSelector:(SEL)aSelector;
+ (IMP)instanceMethodForSelector:(SEL)aSelector;
- (void)doesNotRecognizeSelector:(SEL)aSelector;

- (id)forwardingTargetForSelector:(SEL)aSelector;
- (void)forwardInvocation:(NSInvocation *)anInvocation;
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector;

+ (NSMethodSignature *)instanceMethodSignatureForSelector:(SEL)aSelector;

+ (NSString *)description;

+ (BOOL)isSubclassOfClass:(Class)aClass AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER;

+ (BOOL)resolveClassMethod:(SEL)sel AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
+ (BOOL)resolveInstanceMethod:(SEL)sel AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;

@end

@interface NSObject (NSCoderMethods)

+ (NSInteger)version;
+ (void)setVersion:(NSInteger)aVersion;
- (Class)classForCoder;
- (id)replacementObjectForCoder:(NSCoder *)aCoder;
- (id)awakeAfterUsingCoder:(NSCoder *)aDecoder;

@end

#if (TARGET_OS_MAC && !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE))
@interface NSObject (NSDeprecatedMethods)

+ (void)poseAsClass:(Class)aClass DEPRECATED_IN_MAC_OS_X_VERSION_10_5_AND_LATER
#if __OBJC2__
UNAVAILABLE_ATTRIBUTE
#endif
;

@end
#endif


#if MAC_OS_X_VERSION_10_6 <= MAC_OS_X_VERSION_MAX_ALLOWED

/***********	Discardable Content		***********/

@protocol NSDiscardableContent
@required
- (BOOL)beginContentAccess;
- (void)endContentAccess;
- (void)discardContentIfPossible;
- (BOOL)isContentDiscarded;
@end

@interface NSObject (NSDiscardableContentProxy)
- (id)autoContentAccessingProxy AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
@end

#endif

/***********	Object Allocation / Deallocation		*******/
    
FOUNDATION_EXPORT id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);

FOUNDATION_EXPORT void NSDeallocateObject(id object);

FOUNDATION_EXPORT id NSCopyObject(id object, NSUInteger extraBytes, NSZone *zone);

FOUNDATION_EXPORT BOOL NSShouldRetainWithZone(id anObject, NSZone *requestedZone);

FOUNDATION_EXPORT void NSIncrementExtraRefCount(id object);

FOUNDATION_EXPORT BOOL NSDecrementExtraRefCountWasZero(id object);

FOUNDATION_EXPORT NSUInteger NSExtraRefCount(id object);


 
分享到:
评论

相关推荐

    Objective-C-2.0程序设计-第16章-使用文件PPT课件.ppt

    #import &lt;Foundation/NSObject.h&gt; #import &lt;Foundation/NSString.h&gt; #import &lt;Foundation/NSFileManager.h&gt; #import &lt;Foundation/NSAutoreleasePool.h&gt; #import &lt;Foundation/NSDictionary.h&gt; int main(int argc, ...

    dsdump:改进的nm + Objective-C和Swift类转储

    dsdump 改进的nm + objc / swift类转储.../Users/x/Desktop/classes/NSObject.h /Users/x/Desktop/classes/XMIAudioPlayerListProtocol.h /Users/x/Desktop/classes/UIScrollViewDelegate.h /Users/x/Desktop/classe

    Objective-C对象模型及应用

    本文主要介绍Objective-C对象模型的实现细节,以及Objective-C语言对象模型中对isaswizzling和methodswizzling的支持。希望本文能加深你对Objective-C对象的理解。...在XCode中按Shift+Command+O,然后输入NSObject.h

    iOS 7开发(英文档)

    Xcode then generates two new files for your project: MyClass.h and MyClass.m. They contain the code of an empty class, as in the header and implementation files shown in Listing 1-5 and Listing 1-6. ...

    Object-C中文版

    - 包含在`Foundation`框架中的`NSObject.h`头文件中定义。 **#import与#include**:Objective-C推荐使用`#import`代替`#include`。 - `#import`可以自动处理头文件的重复包含问题,提高了代码的可维护性和效率。 - ...

    Object-C 基础语法中文版

    它包含在 Foundation classes(基本类别库)中(即通过 `import NSObject.h` 引入;nil 也包括在这个头文件内)。在 Objective-C 中,BOOL 有两种形式:YES 或 NO,而不是 TRUE 或 FALSE。 - **#import vs #include*...

    NSObject扩展

    #### 一、NSObject+Jex.h:键盘通知扩展 在给定的代码中,`NSObject`被扩展以处理键盘显示和隐藏的通知。这通常用于响应iOS设备上的键盘行为,如调整视图控制器中的视图布局,以便在键盘弹出时不会遮挡输入字段。 ...

    本地存储NSUserdefault封装(可存储各种类型)

    #import "NSObject+JKLocalStore.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; StudentModel *student = [[StudentModel alloc] init...

    JSON到NSObject的映射库Motis.zip

    // --- User.h --- // @interface User : NSObject @property (nonatomic, strong) NSString *name; @property (nonatomic, assign) NSIntger userId; @property (nonatomic, strong) NSDate *...

    Unity调用Android,IOS剪切板

    @interface ClipboardBridge : NSObject + (void)setText:(NSString *)text; + (NSString *)getText; @end ``` `ClipboardBridge.mm`: ```objc #import "ClipboardBridge.h" #import &lt;UIKit/UIKit.h&gt; @...

    json objective-c代码包

    5. NSObject+SBJSON.h、NSString+SBJSON.h:这两个文件分别为NSObject和NSString类别扩展,提供了便捷的方法,使得任何NSObject的子类和NSString可以直接进行JSON编码和解码。 6. JSON.h:这可能是整个库的核心...

    LRVariadicPerformSelector:简单的NSObject类别,可使用可变参数执行选择器

    LRVariadicPerformSelector 因为有时候,我们需要... 将NSObject+LRVariadicPerformSelector.h/m文件夹NSObject+LRVariadicPerformSelector.h/m您的项目中。用法[self lr_performSelector:@selector(because:sometimes:

    NSObject+RunTimeUtilit

    5. **Category的扩展**:在`NSObject+RunTimeUtility.h`和`NSObject+RunTimeUtility.m`中,很可能定义了一个Category来扩展`NSObject`类,增加了对私有属性操作的相关方法。Category是Objective-C中的一种特性,允许...

    探索NSObject的协议精髓:Objective-C中的基础方法解析

    ### 探索 `NSObject` 的协议精髓:Objective-C 中的基础方法解析 Objective-C 是一种面向对象的编程语言,建立在 C 语言的基础上,增加了面向对象的特性。它最初由 Brad Cox 和 Tom Love 设计,后来被苹果公司采纳...

    AvoidCrash.zip

    这个压缩包包含了两个Objective-C类文件:`NSObject+AvoidCrash.h` 和 `NSObject+AvoidCrash.m`,它们是Category的一种实现,用于扩展NSObject类,增加异常处理机制。 首先,我们来理解Category。Category是...

    AutoPropertyInit:AutoProperty是一个NSObject类别,它简化了NSObject子类的初始化属性的过程。

    自动属性初始化AutoPropertyInit是一个NSObject... # import " AutoInit.h "# import " NSObject+AutoPropertyInit.h "@implementation AutoInit- ( instancetype ) init { self = [ super init ]; if (self) { [ self

    Objective-C 基础语法学习项目

    - **People.h**、**Hi.h**、**Man.h**:自定义类的头文件。 - **ManDelegate.h**:定义了一个名为`ManDelegate`的协议。 ##### 2. 类定义 ```objective-c @interfaceHello:NSObject{ intnum; } -(void)sayHello1; @...

    IOS禁止同步到iCloud的封装类

    `NSObject+YMSkipBackup.h`是头文件,定义了类别(Category)扩展,而`NSObject+YMSkipBackup.m`是实现文件,包含了具体的实现逻辑。 首先,我们来看`NSObject+YMSkipBackup.h`。在这个头文件中,通常会声明一个...

    IOS获取设备型号方法(包括iPhone6 & iPhone6 Plus)

    @interface DevicePlatform : NSObject //返回设备型号 如:iPhone4 或 iPhone6 + (NSString *)platform; //判断是不是iPhone6 + (BOOL)iPhone6; //判断是不是iPhone6Plus + (BOOL)iPhone6Plus; //判断是不是...

Global site tag (gtag.js) - Google Analytics