Re: A Question on estimating +arrayWithCapacity

2009-01-10 Thread Ashley Clark
On Jan 10, 2009, at 2:10 AM, Bill Bumgarner wrote: On Jan 9, 2009, at 7:11 PM, Ashley Clark wrote: This should apply to NSNumber and NSDecimalNumber too right? Yet the NSNumber +numberWith... methods are declared to return (NSNumber *) and when called on NSDecimalNumber they return NSDecim

Re: A Question on estimating +arrayWithCapacity

2009-01-10 Thread Bill Bumgarner
On Jan 9, 2009, at 7:11 PM, Ashley Clark wrote: This should apply to NSNumber and NSDecimalNumber too right? Yet the NSNumber +numberWith... methods are declared to return (NSNumber *) and when called on NSDecimalNumber they return NSDecimalNumber objects which then have to be typecast. Th

Re: A Question on estimating +arrayWithCapacity

2009-01-09 Thread Ashley Clark
This should apply to NSNumber and NSDecimalNumber too right? Yet the NSNumber +numberWith... methods are declared to return (NSNumber *) and when called on NSDecimalNumber they return NSDecimalNumber objects which then have to be typecast. __ Ashley On Jan 9, 2009, at 7:45 PM, mmalc Cr

Re: A Question on estimating +arrayWithCapacity

2009-01-09 Thread Jonathan Hess
+[NSMutableArray array] returns a mutable array. That's the reason the return type is + (id) and not + (NSArray *). When implementing connivence initializers, you should invoke [self alloc], not [ASpecificClass alloc]. Cocoa uses this pattern frequently, and you can safely depend on it. O

Re: A Question on estimating +arrayWithCapacity

2009-01-09 Thread mmalc Crawford
On Jan 9, 2009, at 5:40 PM, Graham Cox wrote: On 10 Jan 2009, at 12:27 pm, Kyle Sluder wrote: Part of the problem that was addressed in the previous thread was that +array is not documented to actually give you a mutable instance. While in practice it works fine, there's no guarantee. Isn't

Re: A Question on estimating +arrayWithCapacity

2009-01-09 Thread Kyle Sluder
On Fri, Jan 9, 2009 at 8:40 PM, Graham Cox wrote: > Isn't guaranteed by the semantics of inheritance? I've specified the class: > [NSMutableArray ... and what I want it to give me... array]; And the fact > that NSMutableArray inherits NSArray ensures that anything that array can > do, NSMutableArr

Re: A Question on estimating +arrayWithCapacity

2009-01-09 Thread Graham Cox
On 10 Jan 2009, at 12:27 pm, Kyle Sluder wrote: Part of the problem that was addressed in the previous thread was that +array is not documented to actually give you a mutable instance. While in practice it works fine, there's no guarantee. Isn't guaranteed by the semantics of inheritance? I'

Re: A Question on estimating +arrayWithCapacity

2009-01-09 Thread Kyle Sluder
On Fri, Jan 9, 2009 at 6:39 PM, Ken Thomases wrote: > And the reason many people don't realize they can do this is that they > overlook the superclass methods when considering a subclass. A lot of > people don't even know that they can send +array to NSMutableArray! Part of the problem that was

Re: A Question on estimating +arrayWithCapacity

2009-01-09 Thread Ken Thomases
On Jan 9, 2009, at 8:11 AM, Graham Cox wrote: On 10 Jan 2009, at 1:07 am, Steve Cronin wrote: Under some circumstances I'm not sure how big a mutable object might need be. So is there any guidance on coming up with a value for capacity? [...] It feels a little like premature optimization,

Re: A Question on estimating +arrayWithCapacity

2009-01-09 Thread Graham Cox
On 10 Jan 2009, at 1:07 am, Steve Cronin wrote: Folks; Under some circumstances I'm not sure how big a mutable object might need be. So is there any guidance on coming up with a value for capacity? Assume for these cases that reasonable guesses range from say 2 - 5000... I assume it's

A Question on estimating +arrayWithCapacity

2009-01-09 Thread Steve Cronin
Folks; Under some circumstances I'm not sure how big a mutable object might need be. So is there any guidance on coming up with a value for capacity? Assume for these cases that reasonable guesses range from say 2 - 5000... I assume it's wasteful to just do a land grab with +arrayWithCapa