• 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: Methods with the same name but different return types
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Methods with the same name but different return types


  • Subject: Re: Methods with the same name but different return types
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 03 Jun 2011 08:15:36 -0700

On Jun 3, 2011, at 12:06 AM, Tony Romano wrote:

> If myValue is of type that myArray
> contains, the cast is unnecessary.  If they don't match, the complier
> should be complaining.

No — NSArrays don’t know what class[es] of object they contain (unlike C++, more like Python or Ruby). Their accessors take and return ‘id’, which is an untyped object pointer. So no cast is necessary when getting an object out of an array or putting one in.

The drawback is that, in this case, the compiler can’t figure out which version of the ‘overloaded’ selector is meant, which can cause trouble. That’s why you want that compiler warning on. But the warning has nothing to do with arrays; this can happen anyplace where an ‘id’ type is messaged.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

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

This email sent to email@hidden

  • Follow-Ups:
    • Re: Methods with the same name but different return types
      • From: Bill Bumgarner <email@hidden>
References: 
 >Re: Methods with the same name but different return types (From: Tony Romano <email@hidden>)

  • Prev by Date: Re: Methods with the same name but different return types
  • Next by Date: Re: Methods with the same name but different return types
  • Previous by thread: Re: Methods with the same name but different return types
  • Next by thread: Re: Methods with the same name but different return types
  • Index(es):
    • Date
    • Thread