MYSRuntime 0.0.5

MYSRuntime 0.0.5

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最后发布2015年1月

Adam Kirk维护。



  • 作者:
  • Adam Kirk

Obj-C库,使运行时自我检查和类修改变得极其简单。

通过使用Objective-C对象封装类的方法和属性,获取类属性的详细信息变得更为简单明了。

从块创建方法并将其添加到类中也非常简单。

示例

轻松获取属性信息

NSArray *properties = [self.klass properties];
for (MYSProperty *property in properties) {
    property.type           // e.g. MYSTypeLongLong
    property.name           // e.g. propertyName
    property.isReadOnly;  
    property.storageType;   // e.g. MYSPropertyStorageTypeStrong
    property.isNonAtomic;
    property.getter;        // the name of the getter method.
    property.setter;        // the name of the setter method.
    property.isDynamic;
    property.isElegibleForGarbageCollection; 
    property.propertyAttributesString; // the original attributes string.
}

轻松从块创建方法并将其作为方法添加到类中。

MYSMethod *testMethod = [[MYSMethod alloc] initWithName:@"setName:age:"
                                    implementationBlock:^(id self, NSString *name, NSNumber *age)
{
    [self setObjectTest:name];
    [self setLongTest:[age longValue]];
}];

MYSClass *testClass   = [[MYSClass alloc] initWithClass:[MYSTestClass class]];
[testClass addMethod:testMethod];

作者:

Adam Kirk @atomkirk

致谢:

使用了CTBlockDescription