Re: Swift - internal class conforming to public protocol
Re: Swift - internal class conforming to public protocol
- Subject: Re: Swift - internal class conforming to public protocol
- From: Marco S Hyman <email@hidden>
- Date: Tue, 24 Nov 2015 23:13:32 -0800
>> if I define an internal class which implements a public protocol, who is able to call the methods in that protocol? Anyone (it’s a public protocol), only classes in the same framework or source file (the class is internal)?
>
> If you declare it internal it's internal. Adopting a public protocol doesn't change that.
There is a specific note in the Swift book:
“If you define a public protocol, the protocol’s requirements require a public access level for those requirements when they are implemented. This behavior is different from other types, where a public type definition implies an access level of internal for the type’s members.”
Excerpt From: Apple Inc. “The Swift Programming Language (Swift 2.1 Prerelease).” iBooks.
As I read that adopting a public protocol requires the methods that implement the protocol to be public (but only those methods).
_______________________________________________
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