> But I am going to need the application to use the instance of the class from 
> when it's started, not make a new instance every time the script command is 
> given.

As Scott mentioned, that's not how the Cocoa framework works with regard to 
AppleScript. It's going to create a new instance of your command subclass every 
time; don't try and fight that. 

It's a structural problem, but one that's easily overcome by splitting apart 
your AppleScript and database logic, which you should probably be doing 
anyways. Similarly, your application delegate should not be your 
NSScriptCommand subclass.

> -(void)applicationDidFinishLaunching:(NSNotification *)aNotification
> {
> userName = NSUserName(); //I also may have tried to retain it but no 
> difference in outcome when Applescript calls the method
> theConnection = [[ODBCConnection alloc] init];

Retaining the ivar might not make a difference now, but you really need to 
understand and implement the Cocoa memory management guidelines. Carelessly 
ignoring the rules because they don't make a difference during testing is 
dangerous and will cause you heartache and lost time later. Also, because your 
subclass doesn't implement a dealloc method, you're leaking that connection 
object. 

I can't stress enough that it's imperative you understand the memory management 
rules.

~Martin

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to