Home

nicerobot edited this page Feb 2, 2012 · 12 revisions
Clone this wiki locally

NRChoice

Specify command-line options with Objective-C object properties.

@interface TestOptions : NRChoice

@property BOOL help;
@property (getter=help,setter=setHelp) BOOL h;

@property BOOL version;
@property (getter=version,setter=setVersion) BOOL v;
@property BOOL verbose;
@property (getter=verbose,setter=setVerbose) BOOL V;

@property int anint;
@property (copy) NSString* astring;
@property (copy,getter=astring,setter=setAstring:) NSString* a;
@property (copy) NSMutableArray* multiple;

@end
@implementation TestOptions
@synthesize help,version,verbose,anint,astring,a,multiple;
@end
TestOptions *cl = [[[TestOptions alloc] init:argc fromArguments:argv] autorelease];
if (cl.help) { usage(); exit 0; }
if (cl.version) { version(); exit 0; }