Re: A Question on estimating +arrayWithCapacity
Re: A Question on estimating +arrayWithCapacity
- Subject: Re: A Question on estimating +arrayWithCapacity
- From: Ashley Clark <email@hidden>
- Date: Fri, 9 Jan 2009 21:11:10 -0600
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 Crawford <email@hidden> wrote:
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 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, NSMutableArray can do.
"The return type of an initializer method should be id.
The reason for this is that id gives an indication that the class is
purposefully not considered―that the class is unspecified and subjec
t to change, depending on context of invocation. For example, NSStri
ng provides a method initWithFormat:. When sent to an instance of NS
MutableString (a subclass of NSString), however, the message returns
an instance ofNSMutableString, not NSString."
_______________________________________________
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