objc_getClass
来源:互联网 发布:网络歌唱大赛 编辑:程序博客网 时间:2024/06/14 17:01
objc_getClass 以类型字符串得到类
/** * Returns the class definition of a specified class. * * @param name The name of the class to look up. * * @return The Class object for the named class, or \c nil * if the class is not registered with the Objective-C runtime. * * @note \c objc_getClass is different from \c objc_lookUpClass in that if the class * is not registered, \c objc_getClass calls the class handler callback and then checks * a second time to see whether the class is registered. \c objc_lookUpClass does * not call the class handler callback. * * @warning Earlier implementations of this function (prior to OS X v10.0) * terminate the program if the class does not exist. */OBJC_EXPORT Class objc_getClass(const char *name) __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);
#import "ViewController.h"#import <objc/runtime.h>#import "Person.h"#import "Dog.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. Class c1 = objc_getClass("Person"); Person * p1 = [[c1 alloc] init]; NSLog(@"%@", p1.name); }
输出:
0 0
- objc_getClass
- 关于runtime的objc_getClass和object_getclass
- c# 日期函数[string.Format----GetDateTimeFormats]格式 .
- android 隐藏自己的多媒体文件
- Protobuf基于java的官方示例演示
- android 将Json数据动态的添加到String[]数组当中
- 天猫浏览型应用的CDN静态化架构演变
- objc_getClass
- springMVC返回的json日期为Long的格式化
- eclipse关联git的方法
- 2015-10-30-03-Android Log使用心得
- 删除MySQL数据库
- nable to resolve target 'android-19'
- 正数数组的最小不可组成和
- windows下sublime text 2的安装使用
- Maven配置文件settings.xml