• 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: Slipp Douglas Thompson <email@hidden>
  • Date: Wed, 21 Sep 2016 20:00:57 -0500

> On Sep 21, 2016, at 17:01 , Graham Cox <email@hidden> wrote:
>>
>> This should be: if([(NSString*)context isEqualToString:@“mediaLibraryLoaded”])…
>
> Actually, this is not a good idea either, because *other* observations — ones you don’t control — might use a value that’s not an object, or not even a valid pointer.


Looking over a couple of open-source implementations of Foundation (cocotron <https://github.com/cjwl/cocotron/blob/master/Foundation/NSString/NSString.m>, PureFoundation <https://github.com/PureDarwin/PureFoundation/blob/master/NSString.m>), the first check done in both isEqual: & isEqualToString: is a pointer == check.

So yes, isEqualToString: could cause issues here so isEqual: is the most sure-fire solution (IMHO)— it shouldn't be any less performant than isEqualToString: and only marginally less performant than a == (due to objc_msgSend overhead).

— Slipp
_______________________________________________

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: Quincey Morris <email@hidden>
    • Re: Stupid objective-c question
      • From: Slipp Douglas Thompson <email@hidden>
References: 
 >Stupid objective-c question (From: Gabriel Zachmann <email@hidden>)
 >Re: Stupid objective-c question (From: Graham Cox <email@hidden>)
 >Re: Stupid objective-c question (From: Quincey Morris <email@hidden>)

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