• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: A Question on estimating +arrayWithCapacity
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A Question on estimating +arrayWithCapacity


  • Subject: Re: A Question on estimating +arrayWithCapacity
  • From: mmalc Crawford <email@hidden>
  • Date: Fri, 09 Jan 2009 17:45:22 -0800


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 subject to change, depending on context of invocation. For example, NSString provides a method initWithFormat:. When sent to an instance of NSMutableString (a subclass of NSString), however, the message returns an instance ofNSMutableString, not NSString."


<http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_4.html#//apple_ref/doc/uid/TP30001163-CH22-SW4 >

mmalc

_______________________________________________

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


  • Follow-Ups:
    • Re: A Question on estimating +arrayWithCapacity
      • From: Ashley Clark <email@hidden>
References: 
 >A Question on estimating +arrayWithCapacity (From: Steve Cronin <email@hidden>)
 >Re: A Question on estimating +arrayWithCapacity (From: Graham Cox <email@hidden>)
 >Re: A Question on estimating +arrayWithCapacity (From: Ken Thomases <email@hidden>)
 >Re: A Question on estimating +arrayWithCapacity (From: "Kyle Sluder" <email@hidden>)
 >Re: A Question on estimating +arrayWithCapacity (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: A Question on estimating +arrayWithCapacity
  • Next by Date: Re: A Question on estimating +arrayWithCapacity
  • Previous by thread: Re: A Question on estimating +arrayWithCapacity
  • Next by thread: Re: A Question on estimating +arrayWithCapacity
  • Index(es):
    • Date
    • Thread