Re: Create an NSCharacterSet constant

2009-11-02 Thread Kyle Sluder
On Mon, Nov 2, 2009 at 8:20 AM, Michael Ash wrote: > Watch out! The 'once' variable must be declared static as well. > Without it, if you're unlucky to get a zero-filled 'once' every time > through, this call will appear to work but leak a new Foo every time > you call it. Oops. Caveat composewi

Re: Create an NSCharacterSet constant

2009-11-02 Thread Michael Ash
On Mon, Nov 2, 2009 at 12:29 AM, Kyle Sluder wrote: > On Sun, Nov 1, 2009 at 9:19 PM, John Joyce > wrote: >> Is it possible to create an NSCharacterSet constant? > > No.  By definition, constants are assigned values at compile time. > Objects other than strings can only be created at runtime.  Th

Re: Create an NSCharacterSet constant

2009-11-01 Thread Kyle Sluder
On Sun, Nov 1, 2009 at 11:03 PM, John Joyce wrote: > I see it as a useful thing to have predefined character sets that don't need > to be managed. So you just want more things like +whitespaceCharacterSet? That makes sense. > At the very least, I will probably submit a radar on adding locale-sp

Re: Create an NSCharacterSet constant

2009-11-01 Thread John Joyce
On Nov 1, 2009, at 11:59 PM, Kyle Sluder wrote: On Sun, Nov 1, 2009 at 9:50 PM, John Joyce wrote: Category, yeah, that's totally one way I thought about, but I was thinking more of an enhancement request in Radar. I figured the nature of it inheriting from NSObject implies there are some k

Re: Create an NSCharacterSet constant

2009-11-01 Thread John Joyce
On Nov 2, 2009, at 12:04 AM, Graham Cox wrote: On 02/11/2009, at 4:50 PM, John Joyce wrote: Category, yeah, that's totally one way I thought about, but I was thinking more of an enhancement request in Radar. I figured the nature of it inheriting from NSObject implies there are some kind

Re: Create an NSCharacterSet constant

2009-11-01 Thread Graham Cox
On 02/11/2009, at 4:50 PM, John Joyce wrote: Category, yeah, that's totally one way I thought about, but I was thinking more of an enhancement request in Radar. I figured the nature of it inheriting from NSObject implies there are some kind of optimizations under the hood (otherwise we'd j

Re: Create an NSCharacterSet constant

2009-11-01 Thread Kyle Sluder
On Sun, Nov 1, 2009 at 9:50 PM, John Joyce wrote: >  Category, yeah, that's totally one way I thought about, but I was thinking > more of an enhancement request in Radar. I figured the nature of it > inheriting from NSObject implies there are some kind of optimizations under > the hood (otherwise

Re: Create an NSCharacterSet constant

2009-11-01 Thread Kyle Sluder
On Sun, Nov 1, 2009 at 9:49 PM, Matt Neuburg wrote: > Why (I'm really asking, not arguing; I don't know anything about GCD) is > this better than the traditional: It avoids a race condition if +sharedFoo is called simultaneously from different threads, and it's wicked fast (Cmd-DoubleClick dispat

Re: Create an NSCharacterSet constant

2009-11-01 Thread John Joyce
On Nov 1, 2009, at 11:32 PM, Graham Cox wrote: On 02/11/2009, at 4:19 PM, John Joyce wrote: Is it possible to create an NSCharacterSet constant? Attempting to do so with the methods for creating an NSCharacterSet naturally fails to compile with "initializer element is not constant" I woul

Re: Create an NSCharacterSet constant

2009-11-01 Thread Matt Neuburg
On Sun, 1 Nov 2009 21:29:25 -0800, Kyle Sluder said: >I'm partial to the following construct: > >+ (Foo *)sharedFoo { > static Foo *sharedFoo; > dispatch_once_t once; > dispatch_once(&once, ^{ sharedFoo = [[foo alloc] init]; } > return sharedfoo; >} Why (I'm really asking, not arguing; I don'

Re: Create an NSCharacterSet constant

2009-11-01 Thread Graham Cox
On 02/11/2009, at 4:19 PM, John Joyce wrote: Is it possible to create an NSCharacterSet constant? Attempting to do so with the methods for creating an NSCharacterSet naturally fails to compile with "initializer element is not constant" I would ideally like to be able to do this. Is it best j

Re: Create an NSCharacterSet constant

2009-11-01 Thread Kyle Sluder
On Sun, Nov 1, 2009 at 9:19 PM, John Joyce wrote: > Is it possible to create an NSCharacterSet constant? No. By definition, constants are assigned values at compile time. Objects other than strings can only be created at runtime. There is no way around this fact. > Is it best just to declare a