How do you call a singleton class method from Objective C in a Swift class? -


i have following objective c code need swift class :

in logger.m -

+ (logger *) log { static logger *sharedlog = nil; static dispatch_once_t oncetoken;  dispatch_once(&oncetoken, ^{     sharedlogger = [[self alloc] init]; });  return sharedlogger; }  - (void) printstring:(nsstring *) s {     nslog(s) } 

which in logger.h -

+ (logger *) log; - (void) printstring:(nsstring *) s; 

now, have code bridged in swift project - loggeruserapp i'm trying use above print method singleton log shared class method.

i've tried -

logger.log().printstring("string")  // compiler error. use object construction logger() logger().log().printstring("string")  // compiler error.  logger().log.printstring("string") // compiler error.  logger.printstring("string") // not call log 

can tell me might going wrong?

i can't reproduce example completely, @ first sight, should work:

logger.log().printstring("string") 

since obj-c singleton function returning singleton (hence logger.log() return singleton.

but since in example code see logger , palog can't if need.


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -