>> 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.
Let me try to paraphrase, in order to check whether I am understanding
Whenever I have two string literals @"XYZ" at different places in the same
and the XYZ are identical, then the compiler (or the Objective-C standard) make
the pointers to those literals are identical?
In other words, the compiler unifies the two occurrences of the two literals,
thus effectively storing only one literal?
> So, this technique is generally Not A Good Idea™.
If my understanding is correct, then I wholeheartedly agree.
That brings me to another question. I've got this piece of code from an
example on MLMediaLibrary.
This is how I start the whole thing:
[mediaLibrary_ addObserver: self
context: (__bridge void *) @"mediaLibraryLoaded"];
And this is the beginning of the corresponding KVO:
- (void) observeValueForKeyPath: (NSString *) keyPath ofObject: (id) object
change: (NSDictionary *) change context: (void *) context
MLMediaSource * mediaSource = [mediaLibrary_.mediaSources objectForKey:
if ( context == (__bridge void *) @"mediaLibraryLoaded" )
So what would be the proper way to do it? Should I just define my own string
Cocoa-dev mailing list (Cocoafirstname.lastname@example.org)
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 arch...@mail-archive.com