Navigation

HOWTO: Stop Cocoa from parsing command line arguments

Friday, September 7th, 2007

Mostly, anyway. While digging around trying to fix bug 366009, I found a user defaults key, NSTreatUnknownArgumentsAsOpen. Example usage:

[[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"];

You need to make that call before -[NSApplication run] is called. Passing a string instead of a boolean is intentional — otherwise, you get a bunch of logs about an NSCFBoolean object to getting compare:options: messages. ;)

Thanks a bunch to whoever made otx. Saved me hours copying offsets from otool output and dereferencing them in gdb.