> Am 24.11.2015 um 15:10 schrieb Roland King <r...@rols.org>:
> 
> 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. 

Maybe I'm misunderstanding something, but I'm not sure why you think this 
should be a problem?

You can always make things more restrictive.

It's the other way around that is not allowed. Say, using an internal protocol 
to define a public class - that wouldn't work, since the user of the class 
might not have access to the internal protocol.

The Swift book says:

----
Guiding Principle of Access Levels

Access levels in Swift follow an overall guiding principle: No entity can be 
defined in terms of another entity that has a lower (more restrictive) access 
level.
----

(I had to find the online version, since iBooks doesn't let me copy from the 
Swift book. WTF?!)

> 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's fine because the class itself is internal. So there's no problem with 
centralManagerDidUpdateState() being internal too.

As you found out, that changes, when you make the class public. Because now the 
user of the class might not be able to access centralManagerDidUpdateState() if 
it's internal.

Disclaimer: I'm still learning Swift myself, so I might have everything totally 
wrong. ;)


Andreas


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to