Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Won't Applescript command use defined ivars?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Won't Applescript command use defined ivars?



On Aug 31, 2011, at 8:58 AM, Chris Paveglio wrote:

> 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.

Well, that's not likely to happen, because that's not the way the framework works.

> I have to connect to a database, and for performance, would rather not have to create/open/use/close/destroy that connection every time it's called (could be called a lot). I would rather have the connection created and ready to use, and then just pass in my calls as needed, until the app quits (it's going to run in the background).

Fine, create it at startup, or on first need, and keep it around. Use a static variable, or some ivars & methods in your app controller class, or create a singleton class (although I don't recommend all the hoohah of enforcing singleton-ness, just create one at startup and keep it in a global variable). You don't have to, and probably shouldn't, stuff all your database connection management into a subclass of an AppleScript command anyway--probably better to abstract that into a class that deals with the database.

--
Scott Ribe
email@hidden
http://www.elevated-dev.com/
(303) 722-0567 voice




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

References: 
 >Won't Applescript command use defined ivars? (From: Chris Paveglio <email@hidden>)
 >Re: Won't Applescript command use defined ivars? (From: Martin Wierschin <email@hidden>)
 >Re: Won't Applescript command use defined ivars? (From: Chris Paveglio <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.