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

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -