ios - Is it a possible for an objective-c class to implement a swift protocol in the .h -


is possible objective-c class implement swift protocol in .h other swift classes can reference objective-c class swift protocol type?

let myswiftprotocol swift protocol type, assume have in .h class:

@protocol myswiftprotocol; @interface myobj : nsobject< myswiftprotocol> 

then i'll warning: cannot find protocol definition myswiftprotocol
warning no good, doesn't work.

so let's assume in .m , remove references protocol in .h.

@interface myobj () <myswiftprotocol> 

then end not being able cast objects of type myobj type myswiftprotocol in swift classes.

so neither approach above works.

please help!

according apple. forward declarations of swift classes , protocols can used types method , property declarations. further apple says, an objective-c class can adopt swift protocol in implementation (.m) file importing xcode generated header swift code...

basically cannot mark obj-c class conforming swift protocol in .h. must in .m , have class pass object expecting reference objc object swift protocol type.

see sections referencing swift class or protocol in objective-c header , adopting swift protocol in objective-c implementation @ https://developer.apple.com/library/ios/documentation/swift/conceptual/buildingcocoaapps/mixandmatch.html


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -