Runtime简单使用

ios runtime

然后我们打开终端,在命令行找到cd到文件目录,然后中输入:

clang -rewrite-objc main.m

命令可以将main.m编译成C++的代码,改成不同的文件名,就会生成不同的c++代码
这是就生成了main.cpp这个c++文件,打开文件代码
查看该main.cpp最底下的main函数,
这样我们就可以看到底层具体实现的方式!

这时,我们就需要知道这些方法:

  • objc_msgSend 可以给对象发送消息
  • objc_getClass(“Person”) 可以获取到指定名称的对象
  • sel_registerName(“alloc”) 可以调用到对象的方法

通过查看,c++代码,我们得出结论:

使用objc_msgSend函数,给objc_getClass函数实例化的对象发送sel_registerName获取到的方法
这么一个消息

增加

增加函数:class_addMethod
增加实例变量:class_addIvar
增加属性:@dynamic标签,或者class_addMethod,因为属性其实就是由getter和setter函数组成
增加Protocol:class_addProtocol 

获取

获取函数列表及每个函数的信息(函数指针、函数名等等):class_getClassMethod method_getName ...
获取属性列表及每个属性的信息:class_copyPropertyList property_getName
获取类本身的信息,如类名等:class_getName class_getInstanceSize
获取变量列表及变量信息:class_copyIvarList

替换

将实例替换成另一个类:object_setClass
将函数替换成一个函数实现:class_replaceMethod
直接通过char *格式的名称来修改变量的值,而不是通过变量

其他如下:

1、对象拷贝:id object_copy(id obj, size_t size)

- (void) copyObj
{
    CustomClass *obj = [CustomClassnew];
    NSLog(@"%p", &obj);
    
    id objTest = object_copy(obj,sizeof(obj));
    NSLog(@"%p", &objTest);

    [objTest fun1];
}
打印结果:
2013-07-26 15:35:11.547 HighOC[6859:c07] 0xbfffdf64
2013-07-26 15:35:11.547 HighOC[6859:c07] 0xbfffdf60
2013-07-26 15:35:11.547 HighOC[6859:c07] fun1

说明:
object_copy 函数实现了对象的拷贝。

2、对象释放 id object_dispose(id obj)

- (void) objectDispose
{
    CustomClass *obj = [CustomClassnew];
    object_dispose(obj);
    
    [obj release];
    [obj fun1];
}
打印结果:程序crash
malloc: *** error for object 0x758e6d0: pointer being freed was not allocated

3、更改对象的类/获取对象的类

Class object_setClass(id obj, Class cls) / Class object_getClass(id obj)

- (void) setClassTest
{
    CustomClass *obj = [CustomClassnew];
    [obj fun1];
    
    Class aClass =object_setClass(obj, [CustomClassOtherclass]);
    //obj 对象的类被更改了    swap the isa to an isa
    NSLog(@"aClass:%@",NSStringFromClass(aClass));
    NSLog(@"obj class:%@",NSStringFromClass([objclass]));
    [obj fun2];
}
- (void) getClassTest
{
    CustomClass *obj = [CustomClassnew];
    Class aLogClass =object_getClass(obj);
    NSLog(@"%@",NSStringFromClass(aLogClass));
}

4、获取对象的类名 constchar *object_getClassName(id obj)

- (void) getClassName
{
    CustomClass *obj = [CustomClassnew];
    NSString *className = [NSStringstringWithCString:object_getClassName(obj)encoding:NSUTF8StringEncoding];
    NSLog(@"className:%@", className);
}

5、给一个类添加方法

BOOL class_addMethod(Class cls,SEL name,IMP imp, const char *types)

/**
  * 一个参数
  */

int cfunction(id self, SEL _cmd, NSString *str) {
    NSLog(@"%@", str);
    return10;//随便返回个值
}

- (void) oneParam {
    
    TestClass *instance = [[TestClassalloc]init];
    //    方法添加
    class_addMethod([TestClassclass],@selector(ocMethod:), (IMP)cfunction,"i@:@");
    
    if ([instance respondsToSelector:@selector(ocMethod:)]) {
        NSLog(@"Yes, instance respondsToSelector:@selector(ocMethod:)");
    } else
    {
        NSLog(@"Sorry");
    }
    
    int a = (int)[instanceocMethod:@"我是一个OC的method,C函数实现"];
    NSLog(@"a:%d", a);
}

 /**
  * 两个参数
  */

int cfunctionA(id self, SEL _cmd, NSString *str, NSString *str1) {
    NSLog(@"%@-%@", str, str1);
    return20;//随便返回个值
}

- (void) twoParam {
    
    TestClass *instance = [[TestClassalloc]init];
    
    class_addMethod([TestClassclass],@selector(ocMethodA::), (IMP)cfunctionA,"i@:@@");
    
    if ([instance respondsToSelector:@selector(ocMethodA::)]) {
        NSLog(@"Yes, instance respondsToSelector:@selector(ocMethodA::)");
    } else
    {
        NSLog(@"Sorry");
    }
    
    int a = (int)[instanceocMethodA:@"我是一个OC的method,C函数实现" :@"-----我是第二个参数"];
    NSLog(@"a:%d", a);
}

相关文档及说明:

Obj-C的方法(method)就是一个至少需要两个参数(self,_cmd)的C函数

IMP有点类似函数指针,指向具体的Method实现。

向一个类动态添加方法

BOOL class_addMethod(Class cls, SEL name, IMP imp, const char *types)

参数说明:

  • cls:被添加方法的类
  • name:可以理解为方法名
  • imp:实现这个方法的函数
  • types:一个定义该函数返回值类型和参数类型的字符串

class_addMethod([TestClass class], @selector(ocMethod:), (IMP)testFunc, "i@:@");

  • 其中types参数为"i@:@“,按顺序分别表示:
  • i:返回值类型int,若是v则表示void
  • @:参数id(self)
  • ::SEL(_cmd)
  • @:id(str)

华丽分割线


一些公用类:

ClassCustomClass.h

@interface ClassCustomClass :NSObject{
    NSString *varTest1;
    NSString *varTest2;
    NSString *varTest3;
}
@property (nonatomic,assign)NSString *varTest1;
@property (nonatomic,assign)NSString *varTest2;
@property (nonatomic,assign)NSString *varTest3;
- (void) fun1;
@end

ClassCustomClass.m

@implementation ClassCustomClass
@synthesize varTest1, varTest2, varTest3;
- (void) fun1 {
    NSLog(@"fun1");
}
@end

ClassCustomClassOther.h

@interface ClassCustomClassOther :NSObject {
    int varTest2;
}
- (void) fun2;
@end

ClassCustomClassOther.m

@implementation ClassCustomClassOther
- (void) fun2 {
    NSLog(@"fun2");
}
@end

ClassPropertyViewCtr.h

@interface ClassPropertyViewCtr () {
    float myFloat;
    ClassCustomClass *allobj;
}
myFloat = 2.34f;

6、获取一个类的所有方法:

- (void) getClassAllMethod
{
    u_int count;
    Method* methods= class_copyMethodList([UIViewController class], &count);
    for (int i = 0; i < count ; i++)
    {
        SEL name = method_getName(methods[i]);
        NSString *strName = [NSString stringWithCString:sel_getName(name)encoding:NSUTF8StringEncoding];
        NSLog(@"%@",strName);
    }
}

打印结果(部分):

2013-07-26 16:07:03.972 HighOC[7021:c07] _screen
2013-07-26 16:07:03.973 HighOC[7021:c07] applicationWillSuspend
2013-07-26 16:07:03.973 HighOC[7021:c07] _tryBecomeRootViewControllerInWindow:
2013-07-26 16:07:03.973 HighOC[7021:c07] isViewLoaded
2013-07-26 16:07:03.974 HighOC[7021:c07] view
......................

7、获取一个类的所有属性:

- (void) propertyNameList
{
    u_int count;
    objc_property_t *properties=class_copyPropertyList([UIViewControllerclass], &count);
    for (int i = 0; i < count ; i++)
    {
        const char* propertyName =property_getName(properties[i]);
        NSString *strName = [NSString stringWithCString:propertyNameencoding:NSUTF8StringEncoding];
        NSLog(@"%@",strName);
    }
}

打印结果(部分)

2013-07-26 16:09:42.182 HighOC[7041:c07] tabBarItem
2013-07-26 16:09:42.184 HighOC[7041:c07] tabBarController
2013-07-26 16:09:42.185 HighOC[7041:c07] splitViewController
2013-07-26 16:09:42.186 HighOC[7041:c07] navigationItem
2013-07-26 16:09:42.186 HighOC[7041:c07] hidesBottomBarWhenPushed
...............

8、获取/设置类的属性变量

//获取全局变量的值   (myFloat 为类的一个属性变量)
- (void) getInstanceVar {
    float myFloatValue;
    object_getInstanceVariable(self,"myFloat", (void*)&myFloatValue);
    NSLog(@"%f", myFloatValue);
}
//设置全局变量的值
- (void) setInstanceVar {
    float newValue = 10.00f;
    unsigned int addr = (unsignedint)&newValue;
    object_setInstanceVariable(self,"myFloat", *(float**)addr);
    NSLog(@"%f", myFloat);
}

9、判断类的某个属性的类型

- (void) getVarType {
    ClassCustomClass *obj = [ClassCustomClassnew];
    Ivar var = class_getInstanceVariable(object_getClass(obj),"varTest1");
    const char* typeEncoding =ivar_getTypeEncoding(var);
    NSString *stringType =  [NSStringstringWithCString:typeEncodingencoding:NSUTF8StringEncoding];
    
    if ([stringType hasPrefix:@"@"]) {
        // handle class case
        NSLog(@"handle class case");
    } else if ([stringTypehasPrefix:@"i"]) {
        // handle int case
        NSLog(@"handle int case");
    } else if ([stringTypehasPrefix:@"f"]) {
        // handle float case
        NSLog(@"handle float case");
    } else
    {
 
    }
}

10、通过属性的值来获取其属性的名字(反射机制)

- (NSString *)nameOfInstance:(id)instance
{
    unsigned int numIvars =0;
    NSString *key=nil;
    
    //Describes the instance variables declared by a class. 
    Ivar * ivars = class_copyIvarList([ClassCustomClassclass], &numIvars);
    
    for(int i = 0; i < numIvars; i++) {
        Ivar thisIvar = ivars[i];
        
        const char *type =ivar_getTypeEncoding(thisIvar);
        NSString *stringType =  [NSStringstringWithCString:typeencoding:NSUTF8StringEncoding];
        
        //不是class就跳过
        if (![stringType hasPrefix:@"@"]) {
            continue;
        }
        
        //Reads the value of an instance variable in an object. object_getIvar这个方法中,当遇到非objective-c对象时,并直接crash
        if ((object_getIvar(allobj, thisIvar) == instance)) {
            // Returns the name of an instance variable.
            key = [NSStringstringWithUTF8String:ivar_getName(thisIvar)];
            break;
        }
    }
    free(ivars);
    return key;
}

测试代码:

allobj = [ClassCustomClassnew];
allobj.varTest1 =@"varTest1String";
allobj.varTest2 =@"varTest2String";
allobj.varTest3 =@"varTest3String";
NSString *str = [selfnameOfInstance:@"varTest1String"];
NSLog(@"str:%@", str);

打印结果:

2013-07-26 16:26:26.271 HighOC[7081:c07] str:varTest1

11、系统类的方法实现部分替换

- (void) methodExchange {
    Method m1 = class_getInstanceMethod([NSStringclass],@selector(lowercaseString));
    Method m2 = class_getInstanceMethod([NSStringclass],@selector(uppercaseString));
    method_exchangeImplementations(m1, m2);
    NSLog(@"%@", [@"sssAAAAss"lowercaseString]);
    NSLog(@"%@", [@"sssAAAAss"uppercaseString]);
}

打印结果:(仔细看log)

2013-07-26 16:33:22.776 HighOC[7104:c07] SSSAAAASS
2013-07-26 16:33:22.778 HighOC[7104:c07] sssaaaass

12、自定义类的方法实现部分替换

- (void) justLog1 {
    NSLog(@"justLog1");
}
- (void) justLog2 {
    NSLog(@"justLog2");
}
- (void) methodSetImplementation {
    Method method = class_getInstanceMethod([ClassMethodViewCtrclass],@selector(justLog1));
    IMP originalImp = method_getImplementation(method);
    Method m1 = class_getInstanceMethod([ClassMethodViewCtrclass],@selector(justLog2));
    method_setImplementation(m1, originalImp);
}
//[self methodSetImplementation];
//[self justLog2];

13、覆盖系统方法

IMP cFuncPointer;
IMP cFuncPointer1;
IMP cFuncPointer2;

NSString* CustomUppercaseString(idself,SEL_cmd){
    printf("真正起作用的是本函数CustomUppercaseString\r\n");
    NSString *string = cFuncPointer(self,_cmd);
    return string;
}
NSArray* CustomComponentsSeparatedByString(idself,SEL_cmd,NSString *str){
    printf("真正起作用的是本函数CustomIsEqualToString\r\n");
    return cFuncPointer1(self,_cmd, str);
}
//不起作用,求解释
bool CustomIsEqualToString(idself,SEL_cmd,NSString *str) {
    printf("真正起作用的是本函数CustomIsEqualToString\r\n");
    return cFuncPointer2(self,_cmd, str);
}
- (void) replaceMethod{
    cFuncPointer = [NSStringinstanceMethodForSelector:@selector(uppercaseString)];
    class_replaceMethod([NSStringclass],@selector(uppercaseString), (IMP)CustomUppercaseString,"@@:");
    cFuncPointer1 = [NSStringinstanceMethodForSelector:@selector(componentsSeparatedByString:)];
    class_replaceMethod([NSStringclass],@selector(componentsSeparatedByString:), (IMP)CustomComponentsSeparatedByString,"@@:@");
    cFuncPointer2 = [NSStringinstanceMethodForSelector:@selector(isEqualToString:)];
    class_replaceMethod([NSStringclass],@selector(isEqualToString:), (IMP)CustomIsEqualToString,"B@:@");
}

14、自动序列化(转)

 #import "NSObject+AutoEncodeDecode.h"
@implementation NSObject (AutoEncodeDecode)
- (void)encodeWithCoder:(NSCoder *)encoder {
    Class cls = [selfclass];
    while (cls != [NSObjectclass]) {
        unsigned int numberOfIvars =0;
        Ivar* ivars = class_copyIvarList(cls, &numberOfIvars);
        for(const Ivar* p = ivars; p < ivars+numberOfIvars; p++){
            Ivar const ivar = *p;
            const char *type =ivar_getTypeEncoding(ivar);
            NSString *key = [NSStringstringWithUTF8String:ivar_getName(ivar)];
            id value = [selfvalueForKey:key];
            if (value) {
                switch (type[0]) {
                    case _C_STRUCT_B: {
                        NSUInteger ivarSize =0;
                        NSUInteger ivarAlignment =0;
                        NSGetSizeAndAlignment(type, &ivarSize, &ivarAlignment);
                        NSData *data = [NSDatadataWithBytes:(constchar *)self + ivar_getOffset(ivar)
                                                      length:ivarSize];
                        [encoder encodeObject:dataforKey:key];
                    }
                        break;
                    default:
                        [encoder encodeObject:value
                                       forKey:key];
                        break;
                }
            }
        }
        free(ivars);
        cls = class_getSuperclass(cls);
    }
}

- (id)initWithCoder:(NSCoder *)decoder {
    self = [self init];
    
    if (self) {
        Class cls = [selfclass];
        while (cls != [NSObjectclass]) {
            unsigned int numberOfIvars =0;
            Ivar* ivars = class_copyIvarList(cls, &numberOfIvars);
            
            for(constIvar* p = ivars; p < ivars+numberOfIvars; p++){
                Ivar const ivar = *p;
                const char *type =ivar_getTypeEncoding(ivar);
                NSString *key = [NSStringstringWithUTF8String:ivar_getName(ivar)];
                id value = [decoder decodeObjectForKey:key];
                if (value) {
                    switch (type[0]) {
                        case _C_STRUCT_B: {
                            NSUInteger ivarSize =0;
                            NSUInteger ivarAlignment =0;
                            NSGetSizeAndAlignment(type, &ivarSize, &ivarAlignment);
                            NSData *data = [decoderdecodeObjectForKey:key];
                            char *sourceIvarLocation = (char*)self+ivar_getOffset(ivar);
                            [data getBytes:sourceIvarLocationlength:ivarSize];
                        }
                            break;
                        default:
                            [self setValue:[decoder decodeObjectForKey:key]
                                    forKey:key];
                            break;
                    }
                }
            }
            free(ivars);
            cls = class_getSuperclass(cls);
        }
    }
    
    return self;
}

用C代替OC:

 #import <objc/runtime.h> 
 #import <objc/message.h>
 #import <stdio.h>

extern int UIApplicationMain (int argc,char *argv[],void *principalClassName,void *delegateClassName);


struct Rect {
  float x;
  float y;
  float width;
  float height;
};
typedef struct Rect Rect;


void *navController;
static int numberOfRows =100;



int tableView_numberOfRowsInSection(void *receiver,structobjc_selector *selector, void *tblview,int section) {
  returnnumberOfRows;
}

void *tableView_cellForRowAtIndexPath(void *receiver,structobjc_selector *selector, void *tblview,void *indexPath) {
  Class TableViewCell = (Class)objc_getClass("UITableViewCell");
  void *cell = class_createInstance(TableViewCell,0);
  objc_msgSend(cell, sel_registerName("init"));
  char buffer[7];
  int row = (int) objc_msgSend(indexPath, sel_registerName("row"));
  sprintf (buffer, "Row %d", row);
  void *label =objc_msgSend(objc_getClass("NSString"),sel_registerName("stringWithUTF8String:"),buffer);
  objc_msgSend(cell, sel_registerName("setText:"),label);
  return cell;
}

void tableView_didSelectRowAtIndexPath(void *receiver,structobjc_selector *selector, void *tblview,void *indexPath) {
  Class ViewController = (Class)objc_getClass("UIViewController");
  void * vc = class_createInstance(ViewController,0);
  objc_msgSend(vc, sel_registerName("init"));
  char buffer[8];
  int row = (int) objc_msgSend(indexPath, sel_registerName("row"));
  sprintf (buffer, "Item %d", row);
  void *label =objc_msgSend(objc_getClass("NSString"),sel_registerName("stringWithUTF8String:"),buffer);
  objc_msgSend(vc, sel_registerName("setTitle:"),label);
  objc_msgSend(navController,sel_registerName("pushViewController:animated:"),vc,1);
}

void *createDataSource() {
  Class superclass = (Class)objc_getClass("NSObject");
  Class DataSource = objc_allocateClassPair(superclass,"DataSource",0);
  class_addMethod(DataSource,sel_registerName("tableView:numberOfRowsInSection:"), (void(*))tableView_numberOfRowsInSection,nil);
  class_addMethod(DataSource,sel_registerName("tableView:cellForRowAtIndexPath:"), (void(*))tableView_cellForRowAtIndexPath,nil);
  objc_registerClassPair(DataSource);
  returnclass_createInstance(DataSource,0);
}

void * createDelegate() {
  Class superclass = (Class)objc_getClass("NSObject");
  Class DataSource = objc_allocateClassPair(superclass,"Delegate",0);
  class_addMethod(DataSource,sel_registerName("tableView:didSelectRowAtIndexPath:"), (void(*))tableView_didSelectRowAtIndexPath,nil);
  objc_registerClassPair(DataSource);
  returnclass_createInstance(DataSource,0);
}



void applicationdidFinishLaunching(void *receiver,structobjc_selector *selector, void *application) {
  Class windowClass = (Class)objc_getClass("UIWindow");
  void * windowInstance = class_createInstance(windowClass, 0);
    
  objc_msgSend(windowInstance, sel_registerName("initWithFrame:"),(Rect){0,0,320,480});
  
  //Make Key and Visiable
  objc_msgSend(windowInstance,sel_registerName("makeKeyAndVisible"));

  //Create Table View
  Class TableViewController = (Class)objc_getClass("UITableViewController");
  void *tableViewController = class_createInstance(TableViewController, 0);
  objc_msgSend(tableViewController, sel_registerName("init"));
  void *tableView = objc_msgSend(tableViewController,sel_registerName("tableView"));
  objc_msgSend(tableView, sel_registerName("setDataSource:"),createDataSource());
  objc_msgSend(tableView, sel_registerName("setDelegate:"),createDelegate());
 
  Class NavController = (Class)objc_getClass("UINavigationController");
  navController = class_createInstance(NavController,0);
  objc_msgSend(navController,sel_registerName("initWithRootViewController:"),tableViewController);
  void *view =objc_msgSend(navController,sel_registerName("view"));
  
  //Add Table View To Window
  objc_msgSend(windowInstance, sel_registerName("addSubview:"),view);
}


//Create an class named "AppDelegate", and return it's name as an instance of class NSString
void *createAppDelegate() {
  Class mySubclass = objc_allocateClassPair((Class)objc_getClass("NSObject"),"AppDelegate",0);
  structobjc_selector *selName =sel_registerName("application:didFinishLaunchingWithOptions:");
  class_addMethod(mySubclass, selName, (void(*))applicationdidFinishLaunching,nil);
  objc_registerClassPair(mySubclass);
  returnobjc_msgSend(objc_getClass("NSString"),sel_registerName("stringWithUTF8String:"),"AppDelegate");
}


int main(int argc, char *argv[]) {
  returnUIApplicationMain(argc, argv,0,createAppDelegate());
}

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

推荐阅读更多精彩内容

  • 转至元数据结尾创建: 董潇伟,最新修改于: 十二月 23, 2016 转至元数据起始第一章:isa和Class一....
    40c0490e5268阅读 1,678评论 0 9
  • 原文出处:南峰子的技术博客 Objective-C语言是一门动态语言,它将很多静态语言在编译和链接时期做的事放到了...
    _烩面_阅读 1,214评论 1 5
  • 我们常常会听说 Objective-C 是一门动态语言,那么这个「动态」表现在哪呢?我想最主要的表现就是 Obje...
    Ethan_Struggle阅读 2,170评论 0 7
  • Objective-C语言是一门动态语言,他将很多静态语言在编译和链接时期做的事情放到了运行时来处理。这种动态语言...
    tigger丨阅读 1,379评论 0 8
  • 继上Runtime梳理(四) 通过前面的学习,我们了解到Objective-C的动态特性:Objective-C不...
    小名一峰阅读 739评论 0 3