• 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: Stupid objective-c question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stupid objective-c question


  • Subject: Re: Stupid objective-c question
  • From: Quincey Morris <email@hidden>
  • Date: Wed, 21 Sep 2016 16:51:31 -0700
  • Feedback-id: 167118m:167118agrif8a:167118sS5zSm_QeE:SMTPCORP

On Sep 21, 2016, at 16:44 , Gabriel Zachmann <email@hidden> wrote:
>
> how can the compiler know that '==' in this case is a NSString comparison?

It can’t because it isn't. What’s being compared are raw pointers. The string value is irrelevant.

> Or is some other magic going on here? if so, which?

No magic, but a (not very good) assumption, that literal strings are unique at run time, so a pointer to a particular literal string is a globally unique identifier.

Incidentally, this assumption is true only within a target. Literal strings in different targets may have different pointers.

So, this technique is generally Not A Good Idea™.

_______________________________________________

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: Stupid objective-c question
      • From: Gabriel Zachmann <email@hidden>
References: 
 >Stupid objective-c question (From: Gabriel Zachmann <email@hidden>)

  • Prev by Date: Stupid objective-c question
  • Next by Date: Re: Stupid objective-c question
  • Previous by thread: Stupid objective-c question
  • Next by thread: Re: Stupid objective-c question
  • Index(es):
    • Date
    • Thread