FROM : Adam P Jenkins
DATE : Fri Feb 15 21:41:52 2008
On Feb 15, 2008, at 3:07 PM, Keith Duncan wrote:
> I hadn't considered the effect that changing the method would have
> on shipping apps - I was simply concerned that the function of the
> method doesn't match it's implied function IMHO.
>
>> for (i = 0; i < 1000; i++) {
>> NSAutoreleasePool *pool = [NSAutoreleasePool new];
>> // do some work
>> [pool drain];
>> }
>
> I like this way of doing things. I don't use -new anywhere else in
> my code but using it for NSAutoreleasePool in a GC app would
> highlight that the pool is a *special* case. This is the pattern
> I'll be using, thanks for that!
As far as I understand, [Foo new] is exactly equivalent to [[Foo
alloc] init], unless Foo has overridden +new to do something else.
I've never understood why most example code shows [[Foo alloc] init]
when [Foo new] is shorter, and I always just use +new. Is there any
reason not to do that?
DATE : Fri Feb 15 21:41:52 2008
On Feb 15, 2008, at 3:07 PM, Keith Duncan wrote:
> I hadn't considered the effect that changing the method would have
> on shipping apps - I was simply concerned that the function of the
> method doesn't match it's implied function IMHO.
>
>> for (i = 0; i < 1000; i++) {
>> NSAutoreleasePool *pool = [NSAutoreleasePool new];
>> // do some work
>> [pool drain];
>> }
>
> I like this way of doing things. I don't use -new anywhere else in
> my code but using it for NSAutoreleasePool in a GC app would
> highlight that the pool is a *special* case. This is the pattern
> I'll be using, thanks for that!
As far as I understand, [Foo new] is exactly equivalent to [[Foo
alloc] init], unless Foo has overridden +new to do something else.
I've never understood why most example code shows [[Foo alloc] init]
when [Foo new] is shorter, and I always just use +new. Is there any
reason not to do that?






Cocoa mail archive

