Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@objc has been deprecated in favour of inheriting from NSObject #37

Open
ghost opened this issue Aug 25, 2015 · 4 comments
Open

@objc has been deprecated in favour of inheriting from NSObject #37

ghost opened this issue Aug 25, 2015 · 4 comments

Comments

@ghost
Copy link

ghost commented Aug 25, 2015

具体的讨论在这里:https://forums.developer.apple.com/thread/11867
查了下最新的官方文档,貌似还没有更新。

@looping
Copy link

looping commented Aug 26, 2015

这个问题应该是修复Xcode6的一个鲜为人知的bug引出的,文档为什么没更新,我想很有可能是目前的解决方案不是最优的。

比如在Xcode7 beta4以前,将@objc(ClassName)用在类SwiftClass上,在Xcode中使用Objective-C调用时,无法使用ClassName,只能使用SwiftClass,但运行时显示的类名又是ClassName
具体可以参考下:http://scottberrevoets.com/2015/07/23/at-objc-class-prefixes-fixed-in-xcode-7-beta-4/

虽然在b4中修复了这个问题,但是使用非ASCII字符命名的Swift类使用@objc(ClassName)后,编译会报如下错误:

Parameter of 'swift_name' attribute must be an ASCII identifier string

还没用Xcode7 beta6测过这个问题。

@onevcat
Copy link
Member

onevcat commented Aug 26, 2015

Thanks。我会查证一下相关内容,然后做一些必要的修改。谢谢!

@onevcat
Copy link
Member

onevcat commented Sep 17, 2015

应该是 Xcode 7 的一个退化。为了解决上面说的问题,Swift 2 中 Apple 引入了 SWIFT_CLASS_NAMED 宏来对 Swift 类型做限制。这个宏里面用了一个 LLVM 的 attribute 导致了非 ascii 码不能通过的问题。

已经提交 rdar://22737851。Apple 应该会有修正这个问题的考虑,所以暂时保留相关内容。

@onevcat
Copy link
Member

onevcat commented Sep 19, 2015

添加了相关说明。issue 保持 open,如果 radar 有反馈的话我也会进一步跟进。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants