I'm a bit new to Swift programming so forgive me if this seems silly. I have a class outside my ViewController that I want to instantiate inside the ViewController, but I am getting an error:
initializer is inaccessible due to 'internal' protection level
The class:
public class TappyBleScanner : NSObject, CBCentralManagerDelegate {
public var manager : CBCentralManager = CBCentralManager(delegate: self, queue : nil)
public init(){} //based on other posts, I thought this would solve it
}
The code in the ViewController:
public func scanForTappyBle() {
var tappyScanner : TappyBleScanner = TappyBleScanner() //<- This is where Xcode 9 reports the error
}
Other posts here and here suggest that making an empty public initializer explicitly would solve this, but the error persists. The Swift documentation seems to suggest that the public no argument init() function would have allowed external modules to access the initializer and hence instantiate this class:
If you want a public type to be initializable with a no-argument initializer when used in another module, you must explicitly provide a public no-argument initializer yourself as part of the type’s definition.
However the error still persists, any ideas?