The Register® — Biting the hand that feeds IT

String theory and the OS X AppKit

Paul Maddox

How is this news? 

Stop

How does this qualify as "Sci/Tech News for the World"? It doesn't even qualify as a particularly interesting blog post.

Anonymous Coward

@Paul Maddox 

Erm, it's not a blog post it's a development article posted in the Software->Developer section.

Brian Webster

Getting localized strings doesn't require private API 

You can get the same thing by using the NSLocalizedStringFromTableInBundle() function, declared in Foundation. Following the example in the post, the call would look like:

NSString* cancelString = NSLocalizedStringFromTableInBundle(@"Cancel", @"Preferences", [NSBundle bundleWithIdentifier:@"com.apple.AppKit"], nil);

You can also do this same trick with any framework that has .strings resources like AppKit has, just substitute the identifier of the framework for @"com.apple.AppKit".

Dave Jewell

RE: Getting localized strings doesn't require private API 

Thanks for that, Brian - interesting. Given the example code you provide, it's easy to see why the Apple developers came up with a more succinct way of doing things. ;-)

Incidentally, _NXKitString is just a wrapper around [NSBundle localizedStringForKey:value:table:], using another undocumented routine to retrieve the bundle instance for AppKit.

Dave