防止模型 赋不到值 崩溃的方法

来源:互联网 发布:小白看什么python教程 编辑:程序博客网 时间:2024/04/29 18:21


.m 实现这两个方法

#import "CounselorListModel.h"


@implementation CounselorListModel



-(void)setValue:(id)value forUndefinedKey:(NSString *)key

{

    

}


-(id)valueForUndefinedKey:(NSString *)key

{

    return nil;

}




//id第一种不行 第二种就可以,是因为我用YYModel还是写错了,先这样吧,以后确定了 再更正

-(void)setValue:(id)value forUndefinedKey:(NSString *)key

{

    if ([key isEqualToString:@"id"]) {

        self.counselorId = [valueintegerValue];

    }

}


+ (NSDictionary *)modelCustomPropertyMapper {

    return@{@"counselorId" :@"id"};

}



@end


0 0