Post

Replies

Boosts

Views

Activity

Reply to How can I call Swift extension method in my Objective-C class?It doesn't work when using @objc.
OK. Thanks for your help. @OOPer In Swift code, there is AESEncrypt method extension for Data in Data+AES.swift class. extension Data {       func AES128Encrypt() throws - Data { ...... } In Objective-C code, I need to call the AESEncrypt method for resultData. But resultData cannot call the AES128Encrypt method. NSData *aesEncryptData = [resultData AES128Encrypt]; When I add @objc in swift extension method, It's showing "@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes".
Topic: Programming Languages SubTopic: Swift Tags:
May ’21
Reply to How can I call Swift extension method in my Objective-C class?It doesn't work when using @objc.
OK. Thanks for your help. @OOPer In Swift code, there is AESEncrypt method extension for Data in Data+AES.swift class. extension Data {       func AES128Encrypt() throws - Data { ...... } In Objective-C code, I need to call the AESEncrypt method for resultData. But resultData cannot call the AES128Encrypt method. NSData *aesEncryptData = [resultData AES128Encrypt]; When I add @objc in swift extension method, It's showing "@objc can only be used with members of classes, @objc protocols, and concrete extensions of classes".
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21
Reply to How can I call Swift extension method in my Objective-C class?It doesn't work when using @objc.
- NSData is automatically bridged to Data in Swift, but it does not mean extension for Data is available in NSData. that is the truth. I will try it and thank you for help.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
May ’21