Re: Stupid objective-c question
Re: Stupid objective-c question
- Subject: Re: Stupid objective-c question
- From: Doug Hill <email@hidden>
- Date: Wed, 21 Sep 2016 22:21:33 -0700
> On Sep 21, 2016, at 10:07 PM, Quincey Morris <email@hidden> wrote:
>
> On Sep 21, 2016, at 21:10 , Doug Hill <email@hidden <mailto:email@hidden>> wrote:
>>
>> I believe the original question was why you can compare a string literal to another object pointer using the == operator and it somehow works.
>
> Actually, we’re more or less on the same page here, but for posterity…
>
> There’s no “somehow” with the == operator. It’s a C thing, not an Obj-C thing, so putting it between two pointers is well-defined, even if either of them happens to be an object reference. Indeed, constructs like "(void*)3" are also a C thing
Just as an example of how this “somehow worked”, but just as easily couldn't:
@“xyz123” == @“xyz123”
isn’t guaranteed to resolve to YES.
Crazy stuff. :)
But I appreciate everyone jumping in on this topic, another thread for the ages.
Doug Hill
_______________________________________________
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