• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Using CLI arguments in controller (scoping?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • compressing an NSString
      • From: stephen rouse <email@hidden>
    • Re: Using CLI arguments in controller (scoping?)
      • From: Lester Dowling <email@hidden>
    • Re: Using CLI arguments in controller (scoping?)
      • From: Mike Blaguszewski <email@hidden>
  • Prev by Date: Re: Question regarding a built app
  • Next by Date: Re: [NSProcessInfo processInfo] environment] only can see my session's env variables via the debugger.
  • Previous by thread: Re: Question regarding a built app
  • Next by thread: Re: Using CLI arguments in controller (scoping?)
  • Index(es):
    • Date
    • Thread