I had a Swift
class declared like this:
@objc class MyHelper {
// class code
}
I had to do this to access such class from Objective-C
classes, since I'm mixing languages in my project. Now that I upgraded to Xcode 7
, I get this error:
Only classes that inherit from NSObject can be declared @objc
And such class is not known by my Objective-C
classes anymore. I guess that then I should inherit my Swift
class from NSObject
, will that have any impact in the way the app was working?
Thanks
See the Apple staff SevenTenEleven's reply in the Apple Developer Forum.
He mentioned that this is because of @objc
on Swift-rooted classes never quite behaved like an NSObject-rooted class, leading to various weirdness in the generated header and at runtime.
We can still treat any Swift class instance as an AnyObject, mark methods and properties on a Swift class as @objc, and conform to Objective-C protocols; the class just isn't exposed in the generated header and doesn't default to having its members available in Objective-C.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With