Re: Methods with the same name but different return types
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