• 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 enums and NSNotificationCenter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Swift enums and NSNotificationCenter


  • Subject: Re: Swift enums and NSNotificationCenter
  • From: Rick Mann <email@hidden>
  • Date: Thu, 06 Aug 2015 10:38:15 -0700

I guess. But we need some kind of extensible way of defining a set of valid selectors, ideally with optional string conformance and raw values (but not required to be strings).

Sent from my iPhone

> On Aug 6, 2015, at 09:20, Jens Alfke <email@hidden> wrote:
>
>
>> On 06 Aug 2015, at 02:19, Rick Mann <email@hidden> wrote:
>>> On Aug 5, 2015, at 17:14 , Jens Alfke <email@hidden> wrote:
>>> It’s part of the language design that only classes support inheritance, not structs or enums.
>>>
>>> Basically, subclassing pass-by-value types is problematic. For example, what happens when you assign a SubclassStruct value to a variable of type BaseStruct, or pass it to a function parameter of type BaseStruct? Do the extra instance variables get chopped off when it’s copied? What happens if you call a BaseStruct method that was overridden in SubclassStruct?
>>>
>>> C++ lets you do this, but it can lead to really nasty problems, so style guides like Effective C++ recommend avoiding it.
>>
>> But for extending the cases in an enum, it seems pretty nice.
>
> You can't do that, because instances of the subclassed enum won’t be valid instances of the super-enum.
>
> Consider enum A which has values x and y. Now subclass it as B and add a value z.
> What happens if you take a variable of type B with value z and assign it to a variable (or pass it to a parameter) of type A? Either you get an A with an illegal value, or you get a runtime exception. Yuck.
>
> —Jens

_______________________________________________

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 enums and NSNotificationCenter
      • From: Marco S Hyman <email@hidden>
References: 
 >Swift enums and NSNotificationCenter (From: Rick Mann <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Charles Srstka <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Rick Mann <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Charles Srstka <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Rick Mann <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Jens Alfke <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Rick Mann <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Uli Kusterer <email@hidden>)
 >Re: Swift enums and NSNotificationCenter (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Improve performance of data structure saved to disk
  • Next by Date: Re: Swift enums and NSNotificationCenter
  • Previous by thread: Re: Swift enums and NSNotificationCenter
  • Next by thread: Re: Swift enums and NSNotificationCenter
  • Index(es):
    • Date
    • Thread