• 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: why does this method return an id?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why does this method return an id?


  • Subject: Re: why does this method return an id?
  • From: Ken Thomases <email@hidden>
  • Date: Sun, 11 Dec 2011 13:53:38 -0600

On Dec 11, 2011, at 12:37 PM, Fritz Anderson wrote:

> Stream of consciousness answer; I don't have time to make it self-consistent.

> With the return type defined as id, the declaration
>
> NSAtrributedString *   attrString = [NSAttributedString string];
>
> is not merely useful, but legal without a downcast.

And, indeed, you did not make it self-consistent.  The above code snippet is neither useful nor legal.  NSAttributedString is not a subclass of NSString and has no +string class method.  For the -string instance method it does have, it would not be safe to assign it to a pointer to NSAttributedString, because it's not an NSAttributedString.

Regards,
Ken

_______________________________________________

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: why does this method return an id?
      • From: Fritz Anderson <email@hidden>
References: 
 >why does this method return an id? (From: Matt Neuburg <email@hidden>)
 >Re: why does this method return an id? (From: Fritz Anderson <email@hidden>)

  • Prev by Date: Re: NSComboBoxCell pop-up list showing
  • Next by Date: Re: why does this method return an id?
  • Previous by thread: Re: why does this method return an id?
  • Next by thread: Re: why does this method return an id?
  • Index(es):
    • Date
    • Thread