Swift - internal class conforming to public protocol
Swift - internal class conforming to public protocol
- Subject: Swift - internal class conforming to public protocol
- From: Roland King <email@hidden>
- Date: Tue, 24 Nov 2015 22:10:40 +0800
I have the following class, it was internal by default, but I’ve made it so explicitly for the purpose of the question.
internal class ControllerBTLEListener: NSObject, CBCentralManagerDelegate
{
// the queue for all our operations
static let queue : dispatch_queue_t = dispatch_queue_create( "BTLE queue", DISPATCH_QUEUE_SERIAL )
// implementation of CBCentralManagerDelegate
func centralManagerDidUpdateState(central: CBCentralManager)
{
}
}
in this class, centralManagerDidUpdateState() is an internal function however the compiler is happy that the class satisfies CBCentralManagerDelegate even though that protocol is public and centralManagerDidUpdateState() is also public. How can this be, how can an internal function make a class conform to a public method on a public protocol. That function is required in the protocol.
It gets stranger. If I change the class from internal to public the I’m required to mark centralManagerDidUpdateState() as public (it would be internal by default) to conform to the protocol so the compiler seems to know that function has to be public, but is allowing it to be internal if the class itself is internal.
Compiler bug or more lack of understanding here?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden