I\'m having some trouble accessing a Swift Singleton from Objective-C.
@objc class SingletonTest: NSObject {
// swiftSharedInstance is not accessible fr
To make members of the SingletonTest class accessible (swiftSharedInstance is a member of this class), use @objcMembers modifier on the class, or add @objc modifier directly on the swiftSharedInstance:
@objc @objcMembers class SingletonTest: NSObject {
// swiftSharedInstance is not accessible from ObjC
class var swiftSharedInstance: SingletonTest {
struct Singleton {
static let instance = SingletonTest()
}
return Singleton.instance
}
}
Or:
@objc class SingletonTest: NSObject {
// swiftSharedInstance is not accessible from ObjC
@objc class var swiftSharedInstance: SingletonTest {
struct Singleton {
static let instance = SingletonTest()
}
return Singleton.instance
}
}