zoukankan      html  css  js  c++  java
  • oc语言基础整理

    objc.h----------------

    typedef struct objc_class *Class;

    struct objc_object {

        Class isa  OBJC_ISA_AVAILABILITY;

    };

    typedef struct objc_object *id;

    #if !OBJC_OLD_DISPATCH_PROTOTYPES

    typedef void (*IMP)(void /* id, SEL, ... */ ); 

    #else

    typedef id (*IMP)(id, SEL, ...); 

    #endif

    /// Type to represent a boolean value.

    #if (TARGET_OS_IPHONE && __LP64__)  ||  TARGET_OS_WATCH

    #define OBJC_BOOL_IS_BOOL 1

    typedef bool BOOL;

    #else

    #define OBJC_BOOL_IS_CHAR 1

    typedef signed char BOOL; 

    runtime.h------------------

    /// An opaque type that represents a method in a class definition.

    typedef struct objc_method *Method;

    /// An opaque type that represents an instance variable.

    typedef struct objc_ivar *Ivar;

    /// An opaque type that represents a category.

    typedef struct objc_category *Category;

    /// An opaque type that represents an Objective-C declared property.

    typedef struct objc_property *objc_property_t;

    struct objc_class {

        Class isa  OBJC_ISA_AVAILABILITY;

    #if !__OBJC2__

        Class super_class                                        OBJC2_UNAVAILABLE;

        const char *name                                         OBJC2_UNAVAILABLE;

        long version                                             OBJC2_UNAVAILABLE;

        long info                                                OBJC2_UNAVAILABLE;

        long instance_size                                       OBJC2_UNAVAILABLE;

        struct objc_ivar_list *ivars                             OBJC2_UNAVAILABLE;

        struct objc_method_list **methodLists                    OBJC2_UNAVAILABLE;

        struct objc_cache *cache                                 OBJC2_UNAVAILABLE;

        struct objc_protocol_list *protocols                     OBJC2_UNAVAILABLE;

    #endif

    } OBJC2_UNAVAILABLE;

    /* Use `Class` instead of `struct objc_class *` */

    struct objc_method {

        SEL method_name                                          OBJC2_UNAVAILABLE;

        char *method_types                                       OBJC2_UNAVAILABLE;

        IMP method_imp                                           OBJC2_UNAVAILABLE;

    }   

    struct objc_category {

        char *category_name                                      OBJC2_UNAVAILABLE;

        char *class_name                                         OBJC2_UNAVAILABLE;

        struct objc_method_list *instance_methods                OBJC2_UNAVAILABLE;

        struct objc_method_list *class_methods                   OBJC2_UNAVAILABLE;

        struct objc_protocol_list *protocols                     OBJC2_UNAVAILABLE;

    }                                                            OBJC2_UNAVAILABLE;

    struct objc_ivar {

        char *ivar_name                                          OBJC2_UNAVAILABLE;

        char *ivar_type                                          OBJC2_UNAVAILABLE;

        int ivar_offset                                          OBJC2_UNAVAILABLE;

    #ifdef __LP64__

        int space                                                OBJC2_UNAVAILABLE;

    #endif

    }

    OBJC_EXPORT void (*_error)(id, const char *, va_list)        OBJC2_UNAVAILABLE;

    Object.h-----------------

    @interface Object

    {

    Class isa; /* A pointer to the instance's class structure */

    }

    NSObject.h-----------------

    @interface NSObject <NSObject> {

        Class isa  OBJC_ISA_AVAILABILITY;

    }

    objc-sync.h----------------

    /** 

     * Begin synchronizing on 'obj'.  

     * Allocates recursive pthread_mutex associated with 'obj' if needed.

     * 

     * @param obj The object to begin synchronizing on.

     * 

     * @return OBJC_SYNC_SUCCESS once lock is acquired.  

     */

    OBJC_EXPORT  int objc_sync_enter(id obj)

        __OSX_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0);

    /** 

     * End synchronizing on 'obj'. 

     * 

     * @param obj The objet to end synchronizing on.

     * 

     * @return OBJC_SYNC_SUCCESS or OBJC_SYNC_NOT_OWNING_THREAD_ERROR

     */

    OBJC_EXPORT  int objc_sync_exit(id obj)

        __OSX_AVAILABLE_STARTING(__MAC_10_3, __IPHONE_2_0);

    // The wait/notify functions have never worked correctly and no longer exist.

    OBJC_EXPORT  int objc_sync_wait(id obj, long long milliSecondsMaxWait) 

        UNAVAILABLE_ATTRIBUTE;

    OBJC_EXPORT  int objc_sync_notify(id obj) 

        UNAVAILABLE_ATTRIBUTE;

    OBJC_EXPORT  int objc_sync_notifyAll(id obj) 

        UNAVAILABLE_ATTRIBUTE;

    集合类--------------

        DEFINED AS: A common class

        HEADER FILES: objc/List.h

    DEPRECATED_ATTRIBUTE

    @interface List : Object

    {

    @public

        id *dataPtr  DEPRECATED_ATTRIBUTE; /* data of the List object */

        unsigned numElements  DEPRECATED_ATTRIBUTE; /* Actual number of elements */

        unsigned maxElements  DEPRECATED_ATTRIBUTE; /* Total allocated elements */

    }

    - (id)makeObjectsPerform:(SEL)aSelector  DEPRECATED_ATTRIBUTE;

    - (id)makeObjectsPerform:(SEL)aSelector with:anObject  DEPRECATED_ATTRIBUTE;

    /*************************************************************************

     * Hash tables of arbitrary data

     *************************************************************************/

    /* This module allows hashing of arbitrary data.  Such data must be pointers or integers, and client is responsible for allocating/deallocating this data.  A deallocation call-back is provided.

    The objective C class HashTable is preferred when dealing with (key, values) associations because it is easier to use in that situation.

    As well-behaved scalable data structures, hash tables double in size when they start becoming full, thus guaranteeing both average constant time access and linear size. */

    typedef struct {

        uintptr_t (*hash)(const void *info, const void *data);

        int (*isEqual)(const void *info, const void *data1, const void *data2);

        void (*free)(const void *info, void *data);

        int style; /* reserved for future expansion; currently 0 */

        } NXHashTablePrototype;

        

    NSObjCRuntime.h----------------

    #if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64

    typedef long NSInteger;

    typedef unsigned long NSUInteger;

    #else

    typedef int NSInteger;

    typedef unsigned int NSUInteger;

    #endif

    objc-exception.h---------------

    typedef struct {

        int version;

        void (*throw_exc)(id); // version 0

        void (*try_enter)(void *); // version 0

        void (*try_exit)(void *); // version 0

        id (*extract)(void *); // version 0

        int (*match)(Class, id); // version 0

    } objc_exception_functions_t;

    objc-load.h-----------------

    OBJC_EXPORT long objc_loadModules (

    char *modlist[], 

    void *errStream,

    void (*class_callback) (Class, Category),

    /*headerType*/ struct mach_header **hdr_addr,

    char *debug_file

    ) OBJC2_UNAVAILABLE;

    OBJC_EXPORT int objc_loadModule (

    char * moduleName, 

    void (*class_callback) (Class, Category),

    int * errorCode

    ) OBJC2_UNAVAILABLE;

    OBJC_EXPORT long objc_unloadModules(

    void *errorStream, /* input (optional) */

    void (*unloadCallback)(Class, Category) /* input (optional) */

    message.h---------------

    /// Specifies the superclass of an instance. 

    struct objc_super {

        /// Specifies an instance of a class.

        __unsafe_unretained id receiver;

        /// Specifies the particular superclass of the instance to message. 

    #if !defined(__cplusplus)  &&  !__OBJC2__

        /* For compatibility with old objc-runtime.h header */

        __unsafe_unretained Class class;

    #else

        __unsafe_unretained Class super_class;

    #endif

        /* super_class is the first class to search */

    };

     * These functions must be cast to an appropriate function pointer type 

     * before being called. 

     */

    #if !OBJC_OLD_DISPATCH_PROTOTYPES

    OBJC_EXPORT void objc_msgSend(void /* id self, SEL op, ... */ )

        __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);

    OBJC_EXPORT void objc_msgSendSuper(void /* struct objc_super *super, SEL op, ... */ )

        __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);

    #else

  • 相关阅读:
    关于 __proto__和prototype的一些理解
    使用siege进行web压力测试
    Access denied for user 'root'@'localhost' (using password: YES)
    博客搬家来咯
    Permutation Transformer【Splay】
    Prime Independence 【LightOJ
    Power Sockets【CF 1469F】【线段树+贪心】
    A Bit Similar【CF 1469E】【unordered_map+bitset】
    brz的树【牛客练习赛72 F】【虚树+dfs序可持久化线段树+树上差分】
    CCA的期望【牛客练习赛74】【数学】
  • 原文地址:https://www.cnblogs.com/feng9exe/p/7234245.html
Copyright © 2011-2022 走看看