• 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: Graham Cox <email@hidden>
  • Date: Thu, 22 Sep 2016 10:01:22 +1000

> On 22 Sep 2016, at 9:44 AM, Gabriel Zachmann <email@hidden> wrote:
>
> I have found on the net

That isn’t always a recommendation ;)


>   if ( context == (__bridge void *) @"mediaLibraryLoaded" )


Don’t do this, even if it appears to work. You got lucky, or are taking advantage of undocumented implementation details.

This should be: if([(NSString*)context isEqualToString:@“mediaLibraryLoaded”])…

I expect the first thing -isEqualToString: does is a pointer comparison, so it’s unlikely to be significantly less performant for the case of when the pointers are literally identical.


—Graham



_______________________________________________

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: Uli Kusterer <email@hidden>
    • Re: Stupid objective-c question
      • From: Quincey Morris <email@hidden>
References: 
 >Stupid objective-c question (From: Gabriel Zachmann <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