Swift enums and NSNotificationCenter

2015-08-05 Thread Rick Mann
I'd like to be able to write code like this: enum MyNotifications : String { case Note1 = "note1" case Note2 = "note2" } let nc = NSNotificationCenter.defaultCenter() nc.postNotificationName(MyNotifications.Note1, nil) But Swift (2.0) doesn't let me do that. Is it possi

Re: Swift enums and NSNotificationCenter

2015-08-05 Thread Charles Srstka
On Aug 5, 2015, at 6:22 PM, Rick Mann wrote: > > I'd like to be able to write code like this: > > enum MyNotifications : String { >case Note1 = "note1" >case Note2 = "note2" > } > > let nc = NSNotificationCenter.defaultCenter() > nc.postNotificationName(MyNotifications.N

Re: Swift enums and NSNotificationCenter

2015-08-05 Thread Rick Mann
> On Aug 5, 2015, at 16:38 , Charles Srstka wrote: > > On Aug 5, 2015, at 6:22 PM, Rick Mann wrote: >> >> I'd like to be able to write code like this: >> >> enum MyNotifications : String { >>case Note1= "note1" >>case Note2= "note2" >> } >> >> let nc =

Re: Swift enums and NSNotificationCenter

2015-08-05 Thread Charles Srstka
On Aug 5, 2015, at 6:45 PM, Rick Mann wrote: > >> >> On Aug 5, 2015, at 16:38 , Charles Srstka > > wrote: >> >> On Aug 5, 2015, at 6:22 PM, Rick Mann wrote: >>> >>> I'd like to be able to write code like this: >>> >>> enum MyNotifications : String { >>> cas

Re: Swift enums and NSNotificationCenter

2015-08-05 Thread Rick Mann
> On Aug 5, 2015, at 16:57 , Charles Srstka wrote: > > I get that error any time I try to subclass *any* enum. I don’t think enums > are supposed to be subclassable. Guess I'll submit a bug. Seems perfectly reasonable to do. -- Rick Mann rm...@latencyzero.com

Re: Swift enums and NSNotificationCenter

2015-08-05 Thread Jens Alfke
> On Aug 5, 2015, at 5:00 PM, Rick Mann wrote: > >> On Aug 5, 2015, at 16:57 , Charles Srstka > > wrote: >> >> I get that error any time I try to subclass *any* enum. I don’t think enums >> are supposed to be subclassable. > > Guess I'll submit a bug. Seems pe

Re: AnyObject and protocols

2015-08-05 Thread Charles Srstka
> On Aug 4, 2015, at 6:23 PM, Rick Mann wrote: > >> On Aug 4, 2015, at 16:22 , Quincey Morris >> wrote: >> >> On Aug 4, 2015, at 15:58 , Rick Mann wrote: >>> >>> I'm curious why, and what the right approach might be? >> >> As to why, the problem is that instances of a type conforming to a p

Re: AnyObject and protocols

2015-08-05 Thread Charles Srstka
I’m just on fire today, aren’t I? Posted this on the wrong thread. Sorry for the noise. Charles > On Aug 5, 2015, at 7:17 PM, Charles Srstka wrote: > >> On Aug 4, 2015, at 6:23 PM, Rick Mann wrote: >> >>> On Aug 4, 2015, at 16:22 , Quincey Morris >>> wrote: >>> >>> On Aug 4, 2015, at 15:5

Re: Swift enums and NSNotificationCenter

2015-08-05 Thread Charles Srstka
> On Aug 5, 2015, at 7:00 PM, Rick Mann wrote: > >> >> On Aug 5, 2015, at 16:57 , Charles Srstka > > wrote: >> >> I get that error any time I try to subclass *any* enum. I don’t think enums >> are supposed to be subclassable. > > Guess I'll submit a bug. Seems

Re: Swift enums and NSNotificationCenter

2015-08-05 Thread Rick Mann
> On Aug 5, 2015, at 17:14 , Jens Alfke wrote: > > >> On Aug 5, 2015, at 5:00 PM, Rick Mann wrote: >> >>> On Aug 5, 2015, at 16:57 , Charles Srstka wrote: >>> >>> I get that error any time I try to subclass *any* enum. I don’t think enums >>> are supposed to be subclassable. >> >> Guess I

Re: Swift enums and NSNotificationCenter

2015-08-05 Thread Charles Srstka
> On Aug 5, 2015, at 7:18 PM, Charles Srstka wrote: > > let foo = NSObject() This line should have been deleted, sorry; it was part of my debugging to try to figure out why the heck I was getting that error, and I forgot to delete it. I should also have posted the console output from running t

Re: Swift enums and NSNotificationCenter

2015-08-05 Thread Rick Mann
Thanks, I'll see what I can make of that. Still not quite as nice as being able to pass an enum to an NSNotificationCenter extension method, but partway there. Would it make sense for Swift to just let you add method implementations to protocols (perhaps as a shortcut to the protocol-extension t

Re: Swift enums and NSNotificationCenter

2015-08-05 Thread Charles Srstka
On Aug 5, 2015, at 7:21 PM, Rick Mann wrote: > > Would it make sense for Swift to just let you add method implementations to > protocols (perhaps as a shortcut to the protocol-extension technique you > used)? That’s what a protocol extension *is*. Charles

Re: Swift enums and NSNotificationCenter

2015-08-05 Thread Rick Mann
> On Aug 5, 2015, at 17:40 , Charles Srstka wrote: > > On Aug 5, 2015, at 7:21 PM, Rick Mann wrote: >> >> Would it make sense for Swift to just let you add method implementations to >> protocols (perhaps as a shortcut to the protocol-extension technique you >> used)? > > That’s what a proto

Improve performance of data structure saved to disk

2015-08-05 Thread Juanjo Conti
Hi there! At the moment I'm using Keyed-Archiving, but after detecting performance issues and read I'm changing to Core-Data. The data structure is a NSMutableDictionary in which keys are instantness of a custom class CookieKey and values and instances of NSHTTPCookie. CookieKey has 3 string prop

Re: Swift enums and NSNotificationCenter

2015-08-05 Thread Quincey Morris
On Aug 5, 2015, at 19:48 , Rick Mann wrote: > > why not be able to also do this? > > protocol MyProtocol { >func myFunc() >{ >some stuff >} > } Chris Lattner has said (in the developer forums) that this seems like an obvious future step for protocols, so perhaps it will com

Re: Improve performance of data structure saved to disk

2015-08-05 Thread Quincey Morris
On Aug 5, 2015, at 20:17 , Juanjo Conti wrote: > > At the moment I'm using Keyed-Archiving, but after detecting performance > issues and read I'm changing to Core-Data. What quantity of entries/records are you talking about here? It’s not going to make a big difference to performance (as oppose

Re: Swift enums and NSNotificationCenter

2015-08-05 Thread Charles Srstka
> On Aug 5, 2015, at 9:48 PM, Rick Mann wrote: > >> >> On Aug 5, 2015, at 17:40 , Charles Srstka > > wrote: >> >> On Aug 5, 2015, at 7:21 PM, Rick Mann > > wrote: >>> >>> Would it make sense for Swift to just let you add method imp

Re: Swift enums and NSNotificationCenter

2015-08-05 Thread Rick Mann
> On Aug 5, 2015, at 20:53 , Charles Srstka wrote: > > Ah, sorry I misunderstood. Yeah, this does seem to be a bit of a no-brainer. No worries, and I agree. Based on Quincey's email, I guess we'll see it eventually. Thanks! -- Rick Mann rm...@latencyzero.com _