美文网首页
iOS子类与父类属性名冲突

iOS子类与父类属性名冲突

作者: SySean | 来源:发表于2017-03-06 11:43 被阅读694次

    当子类的属性定义和父类的属性定义发生冲突时,会有一个warning提示

    Auto property synthesis will not synthesize property 'description' because it is 'readwrite' but it will be synthesized 'readonly' via another proterty

    Paste_Image.png

    解决方案一:修改子类属性名,比如unusualDescription。

    而有时候我们定义Model常常是要解析服务器json数据用的,要求属性字段和服务器返回的字段保持一致,这种情况一般采用方案二

    解决方案二:在子类中显式的声明一个@synthesize description = _description;

    Paste_Image.png

    详解参考:https://segmentfault.com/a/1190000002904657

    相关文章

      网友评论

          本文标题:iOS子类与父类属性名冲突

          本文链接:https://www.haomeiwen.com/subject/mzbygttx.html