Auto property synthesis will not synthesizeproterty;it will be implemented by its superclass, use@dy

本文介绍了在使用Xcode过程中遇到的属性冲突问题及解决方案。当控制器中存在同名属性时,编译器无法确定应合成哪个属性的getter和setter方法。通过使用@dynamic关键字可以告知编译器该属性为动态属性,在编译时确定其归属。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天写demo的时候用到了很早版本的第三方框架,直接给我报了4个错误,当然这是正常的,错误如下:

Auto property synthesis will not synthesizeproterty;it will be implemented by its superclass, use @dynamic to acknowledge intention

意思是编译器自动给属性title合成getter和setter的时候将会在它的父类上实现,也就是说xcode在升级之后控制器里也有一个title属性,现在不知道它到底是哪一个title. 可以通过添加@dynamic告诉编译器这个属性是动态的,意思就是等你编译的时候就知道了它只在此类中合成.

代码如下:

@interface JBBarChartView : JBChartView

//These Two Lines Have The Error
@property (nonatomic, weak) id<JBBarChartViewDataSource, superclassDataSourceIfAvailable> dataSource;
@property (nonatomic, weak) id<JBBarChartViewDelegate, superclassDelegateIfAvailable> delegate;

@end

//MARK:dynamic
@implementation JBBarChartView
@dynamic dataSource;
@dynamic delegate;
@end

//MARK:explicitly synthesize
@implementation JBBarChartView
@synthesize dataSource;
@synthesize delegate;
@end


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值