• 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: Retyping parameters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Retyping parameters


  • Subject: Re: Retyping parameters
  • From: Matt Neuburg <email@hidden>
  • Date: Sun, 03 Jul 2005 08:58:30 -0700

On Fri, 1 Jul 2005 14:17:23 +0100, "Theodore H. Smith" <email@hidden>
said:
>I can implement like this:
>
>- (BOOL)outlineView:(NSOutlineView *)ov isItemExpandable:
>(TaxonomyNode*)item {
>     if (item == nil) { return true; }
>     return [item expandable];
>}
>
>Here, I have declared item to be "TaxonomyNode*" instead of an "id".

That's what an "id" is. It's something that fits any type. Like a pointer to
void, or type O blood.

>I am just asking, is there any reason to avoid doing this?

No - in fact, it's a good idea, because the coercion enables compile-time
type checking within your method. The alternative is to assign "item" to a
TaxonomyNode* in the first line:

>- (BOOL)outlineView:(NSOutlineView *)ov isItemExpandable:
>(id)item {
>    TaxonomyNode* tn = item;
>    if (tn == nil) etc.

But your approach is more elegant. m.

--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide
<http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt>



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: NSSearchField problem under 10.3
  • Next by Date: Error code -10660
  • Previous by thread: Retyping parameters
  • Next by thread: Re: NSCell's cellSize per table column row?
  • Index(es):
    • Date
    • Thread