Accessing Objective-C variables/functions from Swift -


suppose have connector named connector.m (written in objective-c). , create new connector written using swift, named connector.swift. access of variables , methods swift. have create bridging-header , write import of header file of connector. can't access of global variables on objective-c class.

connector.m

nsstring * const khttp_method_get = @"get"; 

connector.swift

public class connector: nsobject {      var parentconnector : connector      override init() {         self.parentconnector = connector     }      func test() {         print(parentconnector.khttp_method_get) //--> error : value of type 'connector' has no member 'khttp_method_get'     }  } 

is possible this? thanks.

add following line in connector.h.

extern nsstring * const khttp_method_get; 

include connector.h bridging header file.


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -