@Objc error when porting to Swift 2

I had a Swift class declared as follows:

 @objc class MyHelper { // class code } 

I had to do this to access the Objective-C class, since I mix languages ​​in my project. Now that I upgraded to Xcode 7 , I get this error:

Only classes that inherit NSObject can be declared by @objc

And this class is not yet known to my Objective-C classes. I assume that then I should inherit my Swift class from NSObject , will this affect how the application works?

thanks

+5
source share
1 answer

Contact Apple SevenTenEleven staff to answer the Apple Developer Forum.

He mentioned that because of @objc in Swift-root classes, it never behaved like an NSObject-based class, which led to various oddities in the generated header and at runtime.

We can process any instance of the Swift class as AnyObject, mark the methods and properties of the Swift class as @objc, and comply with the Objective-C protocols; the class simply does not appear in the generated header and by default does not have its members in Objective-C.

+3
source

All Articles