TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2015 |
Maintained by Steven.
SSObject 支持 CocoaPods. 添加下面的配置到Podfile
:
pod 'SSObject'
@interface SimpleObject : SSObject
@property (nonatomic, strong) SimpleObject * testObj;
@property (nonatomic, strong) NSString * name;
@property (nonatomic, assign) int intValue;
@property (nonatomic, strong) NSArray * testItems;
@property (nonatomic, strong) id value;
@end
@implementation SimpleObject
- (Class)arrayClassWithPropertyName:(NSString *)propertyName {
return SimpleObject.class;
}
@end
NSDictionary * dic = @{ @"testObj": @{ @"name": @"test2",
@"intValue": @(80) },
@"name": @"test1",
@"intValue": @"10",
@"value": @{ @"key1": @"value1" },
@"testItems": @[ @{ @"name": @"testName1"},
@{ @"name": @"testName2"},
@{ @"name": @"testName3"}]};
NSArray * arr = @[ @{@"name": @"testName1"},
@{@"name": @"testName2"},
@{@"name": @"testName3"}];
SimpleObject * obj = [SimpleObject objectWithDictionary:dic];
NSArray * objItems = [SimpleObject arrayWithDictionarys:arr];
NSLog(@"%@", obj);
NSLog(@"%@", obj.dictionaryFormInfo);
NSLog(@"%@", objItems);