• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Swift - internal class conforming to public protocol
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Swift - internal class conforming to public protocol
      • From: Andreas Mayer <email@hidden>
    • Re: Swift - internal class conforming to public protocol
      • From: Quincey Morris <email@hidden>
References: 
 >Swift - internal class conforming to public protocol (From: Roland King <email@hidden>)
 >Re: Swift - internal class conforming to public protocol (From: Andreas Mayer <email@hidden>)
 >Re: Swift - internal class conforming to public protocol (From: Roland King <email@hidden>)
 >Re: Swift - internal class conforming to public protocol (From: Andreas Mayer <email@hidden>)

  • Prev by Date: Re: Swift - internal class conforming to public protocol
  • Next by Date: Re: Swift - internal class conforming to public protocol
  • Previous by thread: Re: Swift - internal class conforming to public protocol
  • Next by thread: Re: Swift - internal class conforming to public protocol
  • Index(es):
    • Date
    • Thread