为什么 objc_super.receiver 在 ARC 中不可用?
如何修复下面第 3 行中的编译器错误 'receiver' is unavailable: this system field has saving opportunity
?
UIKIT_STATIC_INLINE void sample_drawRect(id self, SEL _cmd, CGRect rect) {
struct objc_super super;
super.receiver = self;
super.super_class = class_getSuperclass([self class]);
objc_msgSendSuper(&super, @selector(drawRect:));
}
How do I fix the compiler error 'receiver' is unavailable: this system field has retaining ownership
in line 3 below?
UIKIT_STATIC_INLINE void sample_drawRect(id self, SEL _cmd, CGRect rect) {
struct objc_super super;
super.receiver = self;
super.super_class = class_getSuperclass([self class]);
objc_msgSendSuper(&super, @selector(drawRect:));
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 ARC,C-Structs 无法存储指向 Objective-C 对象的指针。
你尝试过像这样的桥接演员吗?
With ARC, C-Structs can't store pointers to Objective-C objects.
Have you tried a bridging cast, like this?
使用 Objective-C++ 而不是 Objective-C(.mm 文件)。
Use objective-c++ instead of objective-c (.mm file).