• 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: access modifiers in protocols
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: access modifiers in protocols


  • Subject: Re: access modifiers in protocols
  • From: Quincey Morris <email@hidden>
  • Date: Wed, 17 Jun 2015 06:12:05 +0000

On Jun 16, 2015, at 22:37 , Roland King <email@hidden> wrote:
>
> No - can’t have a stored property in an extension

(Someone just asked basically the same question in the dev forums, but with a different example. Was that you?)

The following compiles for me without error:

> public protocol Foo {
> 	mutating func foo( Int )->Void
> }
>
> extension Foo {
> 	internal mutating func fooInternal( Int )->Void {}
> 	public mutating func foo( i: Int )->Void { fooInternal (i)}
> }
>
> internal protocol FooInternal: Foo {
> 	mutating func fooInternal( Int )->Void
> }
>
> internal protocol FooArray: FooInternal {
> 	var bar : Array<Int> { get set }
> }
>
> extension FooArray {
> 	mutating func fooInternal( i: Int )->Void { bar.append( i )}
> }
>
> public struct AFoo: Foo {
> 	public mutating func foo( Int )->Void { print ("cheers")}
> }
>
> public struct BFoo: Foo, FooArray {
> 	var bar : Array<Int> = []
> }

I’m not absolutely sure it does what you want, and if it does I’m not sure it’s the shortest possible sequence. But it compiles without error.



_______________________________________________

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: access modifiers in protocols
      • From: Roland King <email@hidden>
References: 
 >access modifiers in protocols (From: Roland King <email@hidden>)
 >Re: access modifiers in protocols (From: Quincey Morris <email@hidden>)
 >Re: access modifiers in protocols (From: Roland King <email@hidden>)
 >Re: access modifiers in protocols (From: Quincey Morris <email@hidden>)
 >Re: access modifiers in protocols (From: Roland King <email@hidden>)

  • Prev by Date: Re: access modifiers in protocols
  • Next by Date: Re: Language options: Objective-C, Swift, C or C++?
  • Previous by thread: Re: access modifiers in protocols
  • Next by thread: Re: access modifiers in protocols
  • Index(es):
    • Date
    • Thread