利用KVC方法快速为数据对象赋值,如下例
在对应.m文件中
- ( void )setValue:( id )value forUndefinedKey:( NSString *)key
在.h文件中声明如下形式方法:
在对应.m文件中
- (id)initWithDic:(NSDictionary *)dic
{
self = [super init];
if (self)
{
[self setValuesForKeysWithDictionary:dic];
}
return self;
}
- ( void )setValue:( id )value forUndefinedKey:( NSString *)key
{
}