如何将选择器声明为 iOS 属性以及接下来如何使用我的属性?
我接下来写。所有使用 ARC 编写的代码
@interface MPEvent : UIImageView
@property (nonatomic, unsafe_unretained) SEL action;
@property (nonatomic, strong) id target;
@end
选择器是否以正确的方式声明?
在实现中,我接下来这样使用我的属性:
- (void)sendActionToTargetFromView:(id)view {
[target performSelector:action withObject:view];
}
但是编译器向我显示警告
警告:语义问题:PerformSelector 可能会导致泄漏,因为其选择器未知
如何修复此警告?
I write next. All code wrote with ARC
@interface MPEvent : UIImageView
@property (nonatomic, unsafe_unretained) SEL action;
@property (nonatomic, strong) id target;
@end
Is selector declared in correct way?
In implementation I use my properties next this way:
- (void)sendActionToTargetFromView:(id)view {
[target performSelector:action withObject:view];
}
But compiler show me a warning
warning: Semantic Issue: PerformSelector may cause a leak because its selector is unknown
How to fix this warning?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在下面的示例中,仅忽略一行代码 -Warc-performSelector-leaks,之后诊断返回到之前存在的任何状态。
pragma 警告帮助
详细说明
In the below example -Warc-performSelector-leaks is ignored for only a single line of code, after which the diagnostics return to whatever state had previously existed.
pragma warnings help
Detailed description