Objective-C try/catch异常处理机制原理(转)

Objective-C使用@try @catch @finally来捕获并处理异常。处理异常需要用到NSException类,它是所有异常的基类。你可以直接使用NSException类来捕获异常,也可以继承一个新的类。

Objective-C是C语言的扩充,它的异常处理机制是通过C标准库提供两个特殊的函数setjmp()和longjmp()函数实现的。如果对C的异常处理机制和setjmp、longjmp函数不了解的,建议先阅读:C语言异常处理机制。

先来看看下面的例子:

复制代码

import <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
@autoreleasepool
{
@try {
NSException *e = [NSException
exceptionWithName:@"FileNotFoundException"
reason:@"File Not Found on System"
userInfo:nil];
@throw e;
}
@catch (NSException *exception) {
if ([[exception name] isEqualToString:NSInvalidArgumentException]) {
NSLog(@"%@", exception);
} else {
@throw exception;
}
}
@finally {
NSLog(@"finally");
}
}
return 0;
}
复制代码

例子很简单,在@try中抛出一个自定义的FileNotFoundException类型的异常,然后在@catch中判断捕获的异常是不是NSInvalidArgumentException类型,如果不是,将异常再次抛出。最后总是会执行@finally语句,一般异常处理的善后工作都放这里来做。

如何才能了解它内部的工作流程,@try @catch @finally的定义无法查看。幸运的是我们可以通过Clang生成C的中间代码来了解try/catch原理。想了解Clang推荐阅读:编译器Clang介绍。

以上面的代码为例,使用文本编辑器将代码保存到main.m文件中,文件名可随便定义。打开终端输入:clang -rewrite-objc main.m 命令编译。

得到一份main.cpp文件:

复制代码
struct objc_selector; struct objc_class;
struct __rw_objc_super { struct objc_object *object; struct objc_object *superClass; };

ifndef _REWRITER_typedef_Protocol

typedef struct objc_object Protocol;

define _REWRITER_typedef_Protocol

endif

define __OBJC_RW_DLLIMPORT extern

__OBJC_RW_DLLIMPORT struct objc_object *objc_msgSend(struct objc_object *, struct objc_selector *, ...);
__OBJC_RW_DLLIMPORT struct objc_object *objc_msgSendSuper(struct objc_super *, struct objc_selector *, ...);
__OBJC_RW_DLLIMPORT struct objc_object *objc_msgSend_stret(struct objc_object *, struct objc_selector *, ...);
__OBJC_RW_DLLIMPORT struct objc_object *objc_msgSendSuper_stret(struct objc_super *, struct objc_selector *, ...);
__OBJC_RW_DLLIMPORT double objc_msgSend_fpret(struct objc_object *, struct objc_selector *, ...);
__OBJC_RW_DLLIMPORT struct objc_object *objc_getClass(const char *);
__OBJC_RW_DLLIMPORT struct objc_class *class_getSuperclass(struct objc_class *);
__OBJC_RW_DLLIMPORT struct objc_object *objc_getMetaClass(const char *);
__OBJC_RW_DLLIMPORT void objc_exception_throw(struct objc_object *);
__OBJC_RW_DLLIMPORT void objc_exception_try_enter(void *);
__OBJC_RW_DLLIMPORT void objc_exception_try_exit(void *);
__OBJC_RW_DLLIMPORT struct objc_object *objc_exception_extract(void *);
__OBJC_RW_DLLIMPORT int objc_exception_match(struct objc_class *, struct objc_object *);
__OBJC_RW_DLLIMPORT void objc_sync_enter(struct objc_object *);
__OBJC_RW_DLLIMPORT void objc_sync_exit(struct objc_object *);
__OBJC_RW_DLLIMPORT Protocol *objc_getProtocol(const char *);

ifndef __FASTENUMERATIONSTATE

struct __objcFastEnumerationState {
unsigned long state;
void **itemsPtr;
unsigned long *mutationsPtr;
unsigned long extra[5];
};
__OBJC_RW_DLLIMPORT void objc_enumerationMutation(struct objc_object *);

define __FASTENUMERATIONSTATE

endif

ifndef __NSCONSTANTSTRINGIMPL

struct __NSConstantStringImpl {
int *isa;
int flags;
char *str;
long length;
};

ifdef CF_EXPORT_CONSTANT_STRING

extern "C" __declspec(dllexport) int __CFConstantStringClassReference[];

else

__OBJC_RW_DLLIMPORT int __CFConstantStringClassReference[];

endif

define __NSCONSTANTSTRINGIMPL

endif

ifndef BLOCK_IMPL

define BLOCK_IMPL

struct __block_impl {
void *isa;
int Flags;
int Reserved;
void *FuncPtr;
};
// Runtime copy/destroy helper functions (from Block_private.h)

ifdef __OBJC_EXPORT_BLOCKS

extern "C" __declspec(dllexport) void _Block_object_assign(void *, const void *, const int);
extern "C" __declspec(dllexport) void _Block_object_dispose(const void *, const int);
extern "C" __declspec(dllexport) void *_NSConcreteGlobalBlock[32];
extern "C" __declspec(dllexport) void *_NSConcreteStackBlock[32];

else

__OBJC_RW_DLLIMPORT void _Block_object_assign(void *, const void *, const int);
__OBJC_RW_DLLIMPORT void _Block_object_dispose(const void *, const int);
__OBJC_RW_DLLIMPORT void *_NSConcreteGlobalBlock[32];
__OBJC_RW_DLLIMPORT void *_NSConcreteStackBlock[32];

endif

endif

define __block

define __weak

define OFFSETOFIVAR(TYPE, MEMBER) ((long long) &((TYPE *)0)->MEMBER)

static __NSConstantStringImpl __NSConstantStringImpl_main_m_0 attribute ((section ("__DATA, __cfstring"))) = {__CFConstantStringClassReference,0x000007c8,"FileNotFoundException",21};
static __NSConstantStringImpl __NSConstantStringImpl_main_m_1 attribute ((section ("__DATA, __cfstring"))) = {__CFConstantStringClassReference,0x000007c8,"File Not Found on System",24};
static __NSConstantStringImpl __NSConstantStringImpl_main_m_2 attribute ((section ("__DATA, __cfstring"))) = {__CFConstantStringClassReference,0x000007c8,"%@",2};
static __NSConstantStringImpl __NSConstantStringImpl_main_m_3 attribute ((section ("__DATA, __cfstring"))) = {__CFConstantStringClassReference,0x000007c8,"finally",7};
//
// main.c
// TestBlock
//
// Created by xxxx on 13-6-2.
// Copyright (c) 2013 xxxx. All rights reserved.
//

include <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
@autoreleasepool
{
/* @try scope begin /
{
struct _objc_exception_data
{
int buf[18/
32-bit i386*/];
char *pointers[4];
} _stack;

        id volatile _rethrow = 0;
        objc_exception_try_enter(&_stack);
        
        if (!_setjmp(_stack.buf)) /* @try block continue */
        {
            NSException *e = ((NSException *(*)(id, SEL, NSString *, NSString *, NSDictionary *))(void *)objc_msgSend)(objc_getClass("NSException"), sel_registerName("exceptionWithName:reason:userInfo:"), (NSString *)&__NSConstantStringImpl_main_m_0, (NSString *)&__NSConstantStringImpl_main_m_1, (NSDictionary *)((void *)0));
            
            objc_exception_throw(e);
            
        } /* @catch begin */ else {
            
            id _caught = objc_exception_extract(&_stack);
            objc_exception_try_enter (&_stack);
            
            if (_setjmp(_stack.buf))
                _rethrow = objc_exception_extract(&_stack);
            
            else { /* @catch continue */
                if (objc_exception_match((struct objc_class *)objc_getClass("NSException"), (struct objc_object *)_caught)) {
                    NSException *exception = _caught;
                    
                    if (((BOOL (*)(id, SEL, NSString *))(void *)objc_msgSend)((id)((NSString *(*)(id, SEL))(void *)objc_msgSend)((id)exception, sel_registerName("name")), sel_registerName("isEqualToString:"), (NSString *)NSInvalidArgumentException)) {
                        
                        NSLog((NSString *)&__NSConstantStringImpl_main_m_2, exception);
                    } else {
                        
                        objc_exception_throw( exception);
                    }
                    
                } /* last catch end */ else {
                    _rethrow = _caught;
                    objc_exception_try_exit(&_stack);
                }
            } /* @catch end */
        }
        /* @finally */
        {
            if (!_rethrow) objc_exception_try_exit(&_stack);

            NSLog((NSString *)&__NSConstantStringImpl_main_m_3);
            
            if (_rethrow) objc_exception_throw(_rethrow);
        }
        
    } /* @try scope end */

}
return 0;

}
复制代码

文件中信息量太大,咱们只看main函数部分,下面的代码把main函数的代码作了注释说明:

复制代码

include <Foundation/Foundation.h>

int main (int argc, const char * argv[])
{
@autoreleasepool
{
/**
* try/catch的作用域从这里开始
/
/
@try scope begin /
{
/
*
* 首先定义一个_objc_exception_data类型的结构体,用来保存异常现场的数据。
/
struct _objc_exception_data
{
/
*
* buf变量就是c语言中的jmp_buf
* jmp_buf的定义可在setjmp.h文件中找到:
*
* #define _JBLEN (10 + 16 + 2)
* #define _JBLEN_MAX _JBLEN
*
* typedef int jmp_buf[_JBLEN];
/
int buf[18/
32-bit i386*/];

            /**
             * pointers[0]用来存储通过@throw抛出的异常对象,
             * pointers[1]存储下一个_stack数据。
             */
            char *pointers[4];
        } _stack;
        
        /**
         * _rethrow保存可能在@catch中再次抛出的异常对象。
         */
        id volatile _rethrow = 0;
        
        /**
         * 因为异常处理支持嵌套,_stack会被存储在一个全局的栈中,这个栈用单链表的存储结构表示。
         * objc_exception_try_enter函数将_stack压栈。
         */
        objc_exception_try_enter(&_stack);
        
        /**
         * _setjmp是C的函数,用于保存当前程序现场。
         * _setjmp需要传入一个jmp_buf参数,保存当前需要用到的寄存器的值。
         * _setjmp()它能返回两次,第一次是初始化时,返回0,第二次遇到_longjmp()函数调用会返回,返回值由_longjmp的第二个参数决定。
         * 如果对_setjmp()和_longjmp()概念不太了解的,请参考C语言的异常处理机制。
         *
         * 下面_setjmp()初始化返回0,然后执行if{}中也就是@try{}中的代码。
         */
        if (!_setjmp(_stack.buf)) /* @try block continue */
        {
            /**
             * 创建一个NSException对象,对应代码:
             * 
             *             NSException *e = [NSException
             *                               exceptionWithName:@"FileNotFoundException"
             *                               reason:@"File Not Found on System"
             *                               userInfo:nil];
             */
            NSException *e = ((NSException *(*)(id, SEL, NSString *, NSString *, NSDictionary *))(void *)objc_msgSend)(objc_getClass("NSException"), sel_registerName("exceptionWithName:reason:userInfo:"), (NSString *)&__NSConstantStringImpl_main_m_0, (NSString *)&__NSConstantStringImpl_main_m_1, (NSDictionary *)((void *)0));
            
            /**
             * 抛出异常对象,对应代码:@throw e;
             * 
             * objc_exception_throw函数实现步骤如下:
             * 1. 把e对象保存到_stack->pointers[0]中使其在@catch{}中能被捕获。
             * 2. 将_stack从全局栈中弹出。
             * 3. 调用_longjmp()跳转到前面if语句中的_setjmp()位置。_longjmp()使得_setjmp()函数第二次返回,
             * 返回值为1,所以会执行else{}中也就是@catch{}中的代码。
             */
            objc_exception_throw(e);
            
        } /* @catch begin */ else {
            
            /**
             * objc_exception_extract函数从_stack->pointers[0]中取得上面抛出的异常对象。
             */
            id _caught = objc_exception_extract(&_stack);
            
            /**
             * 这里为何再次调用objc_exception_try_enter对_stack压栈?先保留这个疑问,继续看下面的代码。
             */
            objc_exception_try_enter (&_stack);
            
            /**
             * 在@catch中设置一个跳转位置
             */
            if (_setjmp(_stack.buf))
                
                /**
                 * 如果@catch{}中再次抛出异常,在这里捕获。
                 */
                _rethrow = objc_exception_extract(&_stack);
            
            else { /* @catch continue */
                
                /**
                 * objc_exception_match函数判断_caught对象是否是需要捕获的目标对象。对应代码:
                 * 
                 * @catch (NSException *exception) {
                 */
                if (objc_exception_match((struct objc_class *)objc_getClass("NSException"), (struct objc_object *)_caught)) {
                    NSException *exception = _caught;
                    
                    /**
                     * 比较捕获的异常是不是NSInvalidArgumentException类型。对应代码:
                     *
                     * if ([[exception name] isEqualToString:NSInvalidArgumentException]) {
                     *      NSLog(@"%@", exception);
                     *
                     */ 
                    if (((BOOL (*)(id, SEL, NSString *))(void *)objc_msgSend)((id)((NSString *(*)(id, SEL))(void *)objc_msgSend)((id)exception, sel_registerName("name")), sel_registerName("isEqualToString:"), (NSString *)NSInvalidArgumentException)) {
                        
                        NSLog((NSString *)&__NSConstantStringImpl_main_m_2, exception);
                    } else {
                        
                        /**
                         * 抛出异常对象,然后跳转到前面@catch中的if语句中的_setjmp()位置。
                         * 这就解释了前面为什么要在@catch中再次将_stack压栈和调用_setjmp()的原因。
                         * 在当前@catch中,如果不设置一个跳转点来捕获@catch中抛出的异常,那么程序就直接跳转到全局栈的下一个@catch中,而下面的@finally{}代码就无法执行。
                         * 在@catch中设置跳转点就是为了最后总能执行@finally中的代码。
                         */
                        objc_exception_throw( exception);
                    }
                    
                } /* last catch end */ else {
                    
                    /**
                     * 如果异常对象没被处理,先将其保存到_rethrow变量。
                     * objc_exception_try_exit函数将_stack从全局栈中弹出。
                     */
                    _rethrow = _caught;
                    objc_exception_try_exit(&_stack);
                }
            } /* @catch end */
        }
        /* @finally */
        {
            if (!_rethrow) objc_exception_try_exit(&_stack);

            NSLog((NSString *)&__NSConstantStringImpl_main_m_3);
            
            /**
             * _rethrow是前面@catch中没有被处理的或被捕获的异常对象,
             * 最后,_rethrow异常对象被抛到全局栈的下一个@catch中。
             */
            if (_rethrow) objc_exception_throw(_rethrow);
        }
        
    } /* @try scope end */

}
return 0;

}
复制代码

以上代码中还涉及了objc_exception_try_enter、objc_exception_extract、objc_exception_throw、objc_exception_try_exit等函数,这些函数可以在苹果开源的objc4的objc-exception.mm文件中找到,objc4源码可在这里下载。下面代码只显示部分方便阅读:

复制代码
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;

static objc_exception_functions_t xtab;

// forward declaration
static void set_default_handlers();

/*

  • Exported functions
    */

// get table; version tells how many
void objc_exception_get_functions(objc_exception_functions_t *table) {
// only version 0 supported at this point
if (table && table->version == 0)
*table = xtab;
}

// set table
void objc_exception_set_functions(objc_exception_functions_t *table) {
// only version 0 supported at this point
if (table && table->version == 0)
xtab = *table;
}

/*

  • The following functions are
  • synthesized by the compiler upon encountering language constructs
    */

void objc_exception_throw(id exception) {
if (!xtab.throw_exc) {
set_default_handlers();
}

if (PrintExceptionThrow) {
    _objc_inform("EXCEPTIONS: throwing %p (%s)", 
                 exception, object_getClassName(exception));
    void* callstack[500];
    int frameCount = backtrace(callstack, 500);
    backtrace_symbols_fd(callstack, frameCount, fileno(stderr));
}

OBJC_RUNTIME_OBJC_EXCEPTION_THROW(exception);  // dtrace probe to log throw activity.
xtab.throw_exc(exception);
_objc_fatal("objc_exception_throw failed");

}

void objc_exception_try_enter(void *localExceptionData) {
if (!xtab.throw_exc) {
set_default_handlers();
}
xtab.try_enter(localExceptionData);
}

void objc_exception_try_exit(void *localExceptionData) {
if (!xtab.throw_exc) {
set_default_handlers();
}
xtab.try_exit(localExceptionData);
}

id objc_exception_extract(void *localExceptionData) {
if (!xtab.throw_exc) {
set_default_handlers();
}
return xtab.extract(localExceptionData);
}

int objc_exception_match(Class exceptionClass, id exception) {
if (!xtab.throw_exc) {
set_default_handlers();
}
return xtab.match(exceptionClass, exception);
}

// quick and dirty exception handling code
// default implementation - mostly a toy for use outside/before Foundation
// provides its implementation
// Perhaps the default implementation should just complain loudly and quit

extern void _objc_inform(const char *fmt, ...);

typedef struct { jmp_buf buf; void *pointers[4]; } LocalData_t;

typedef struct _threadChain {
LocalData_t *topHandler;
objc_thread_t perThreadID;
struct _threadChain *next;
}
ThreadChainLink_t;

static ThreadChainLink_t ThreadChainLink;

static ThreadChainLink_t *getChainLink() {
// follow links until thread_self() found (someday) XXX
objc_thread_t self = thread_self();
ThreadChainLink_t *walker = &ThreadChainLink;
while (walker->perThreadID != self) {
if (walker->next != NULL) {
walker = walker->next;
continue;
}
// create a new one
// XXX not thread safe (!)
// XXX Also, we don't register to deallocate on thread death
walker->next = (ThreadChainLink_t *)malloc(sizeof(ThreadChainLink_t));
walker = walker->next;
walker->next = NULL;
walker->topHandler = NULL;
walker->perThreadID = self;
}
return walker;
}

static void default_try_enter(void *localExceptionData) {
LocalData_t *data = (LocalData_t *)localExceptionData;
ThreadChainLink_t *chainLink = getChainLink();
data->pointers[1] = chainLink->topHandler;
chainLink->topHandler = data;
if (PrintExceptions) _objc_inform("EXCEPTIONS: entered try block %p\n", chainLink->topHandler);
}

static void default_throw(id value) {
ThreadChainLink_t *chainLink = getChainLink();
LocalData_t *led;
if (value == nil) {
if (PrintExceptions) _objc_inform("EXCEPTIONS: objc_exception_throw with nil value\n");
return;
}
if (chainLink == NULL) {
if (PrintExceptions) _objc_inform("EXCEPTIONS: No handler in place!\n");
return;
}
if (PrintExceptions) _objc_inform("EXCEPTIONS: exception thrown, going to handler block %p\n", chainLink->topHandler);
led = chainLink->topHandler;
chainLink->topHandler = (LocalData_t *)
led->pointers[1]; // pop top handler
led->pointers[0] = value; // store exception that is thrown

if TARGET_OS_WIN32

longjmp(led->buf, 1);

else

_longjmp(led->buf, 1);

endif

}

static void default_try_exit(void *led) {
ThreadChainLink_t *chainLink = getChainLink();
if (!chainLink || led != chainLink->topHandler) {
if (PrintExceptions) _objc_inform("EXCEPTIONS: *** mismatched try block exit handlers\n");
return;
}
if (PrintExceptions) _objc_inform("EXCEPTIONS: removing try block handler %p\n", chainLink->topHandler);
chainLink->topHandler = (LocalData_t *)
chainLink->topHandler->pointers[1]; // pop top handler
}

static id default_extract(void *localExceptionData) {
LocalData_t *led = (LocalData_t *)localExceptionData;
return (id)led->pointers[0];
}

static int default_match(Class exceptionClass, id exception) {
//return [exception isKindOfClass:exceptionClass];
Class cls;
for (cls = _object_getClass(exception); nil != cls; cls = _class_getSuperclass(cls))
if (cls == exceptionClass) return 1;
return 0;
}

static void set_default_handlers() {
objc_exception_functions_t default_functions = {
0, default_throw, default_try_enter, default_try_exit, default_extract, default_match };

// should this always print?
if (PrintExceptions) _objc_inform("EXCEPTIONS: *** Setting default (non-Foundation) exception mechanism\n");
objc_exception_set_functions(&default_functions);

}

void exception_init(void)
{
// nothing to do
}

void _destroyAltHandlerList(struct alt_handler_list *list)
{
// nothing to do
}

// !OBJC2

else

// OBJC2
复制代码

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 157,373评论 4 361
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 66,732评论 1 290
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 107,163评论 0 238
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,700评论 0 202
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,036评论 3 286
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,425评论 1 211
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,737评论 2 310
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,421评论 0 194
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,141评论 1 239
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,398评论 2 243
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,908评论 1 257
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,276评论 2 251
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,907评论 3 233
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,018评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,772评论 0 192
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,448评论 2 269
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,325评论 2 261

推荐阅读更多精彩内容

  • 转至元数据结尾创建: 董潇伟,最新修改于: 十二月 23, 2016 转至元数据起始第一章:isa和Class一....
    40c0490e5268阅读 1,633评论 0 9
  • 消息发送和转发流程可以概括为:消息发送(Messaging)是 Runtime 通过 selector 快速查找 ...
    lylaut阅读 1,744评论 2 3
  • 1. Java基础部分 基础部分的顺序:基本语法,类相关的语法,内部类的语法,继承相关的语法,异常的语法,线程的语...
    子非鱼_t_阅读 31,292评论 18 399
  • 接着上节 condition_varible ,本节主要介绍future的内容,练习代码地址。本文参考http:/...
    jorion阅读 14,474评论 1 5
  • 我们常常会听说 Objective-C 是一门动态语言,那么这个「动态」表现在哪呢?我想最主要的表现就是 Obje...
    Ethan_Struggle阅读 2,109评论 0 7