如何保障iOS代码#高质量#之警告设置(5)

217 阅读1分钟
  • 代码示例如图: image.png

  • 声明的protocol里的property是不会自动synthesize

  • 这种情况下如果调用protocol里的property,就会因为找不到方法而崩溃

  • 警告说明如图: 说明链接 image.png

  • 警告提示内容

Auto property synthesis will not synthesize property 'title' declared in protocol 'BaseModelProtocol'
  • 解决办法:手动实现synthesize
#import "BaseModel.h"

@implementation BaseModel

@synthesize title; /// 手动实现synthesize

@end