字典与自定义对象的相互转换

字典  -> 自定义对象:

self setValuesForKeysWithDictionary:<#(nonnull NSDictionary<NSString *,id> *)#>

 

自定义对象  ->  字典:

    Person *p = [[Person alloc] init];

    p.name = @"小明";

    p.age = 20;

    

    NSDictionary *dict = [p dictionaryWithValuesForKeys:@[@"name",@"age"]];

    NSLog(@"%@",dict);

posted @ 2017-01-14 12:46  小课桌  阅读(203)  评论(0编辑  收藏  举报