Using CLI arguments in controller (scoping?)
Using CLI arguments in controller (scoping?)
- Subject: Using CLI arguments in controller (scoping?)
- From: Andrew Pouliot <email@hidden>
- Date: Fri, 12 May 2006 13:37:22 -0700
Here's the deal:
I'm trying to get options specified on the command line to be visible
in my controller class (instantiated in .nib file).
main.m:
#import <Cocoa/Cocoa.h>
#import "TestController.h"
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
if (argv[1] != nil)
defaultSound = [[NSString stringWithCString:argv[1]] retain];
if (argv[2] != nil)
defaultClassName = [[NSString stringWithCString:argv[2]] retain];
[pool release];
NSLog(@"Opening with %s, %s",argv[1],argv[2]);
return NSApplicationMain(argc, (const char **) argv);
}
-------------------------
TestController.h:
NSString *defaultSound;
NSString *defaultClassName;
@interface TestController : NSObject
{
…
}
@end
-------------------------
in TestController.m:
- (void)awakeFromNib {
…
if (defaultClassName != nil) {
//do something
}
if (defaultSound != nil) {
//do something
}
}
When I set a breakpoint in awakeFromNib, and ask GDB what
defaultClassName's value is, it prints out the correct string.
However, the code doesn't seem to be seeing the value, because the //
do something block is never reached. When I declared local variables
right before that section that just copied those values, these got
nil values. I assume that I've screwed something up with scoping.
Any help would be greatly appreciated!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden