> On Sep 21, 2016, at 17:01 , Graham Cox <graham....@bigpond.com> 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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com