Monday, April 22, 2019

#1 2018-12-11 09:55:49 pm

technomorph
Member
Registered: 2017-12-14
Posts: 103

Multiple ASObjC scripts in Xcode Project? What's correct "Structure"

So in developing my app I being working on separate sections of it as separate scripts
and packaging some of them into libraries.

I have already built an Xcode project with one of my ASObjC scripts/script libraries
and I want to now use some of these new scripts/script libraries and further develop the app.
I'm wondering about using multiple ASObjC scripts in the Xcode projects
as I believe I've seen this in other projects.

Few questions
1) do I still need to add the regular AppDelegate methods to the scripts.
- AppWillFinishLaunching etc?
2) A) would I want to make the added scripts Delegates of the Main Script?
    B) if I do make them Delegates do I really need to have the -App Will Finish Launch stuff
3) am I not approaching this correctly and should I be doing the following:

Other Design Approach:
- Should I be considering the AppDelegate Applescript as the front end connection between
Cocoa and the rest of my applescript?    IE it is my controller and view controller between the AppleScript world and Cocoa world?

- Should I design the AppDelegate so that has the properties and functions for VIEW CONTROLLING
- and also the AppDelegate would be my DATA/MODEL CONTROLLER and utilize the other scripts as libraries?
- Take advantage of as many Xcode Controllers that I can to reduce the code in the AppDelegate?

If I can use multiple AppDelegate should I use the above MVC design approach
and have each AppDelegate Script handle separate "sections" of my code?
IE
- one for handling Data importing, managing, moving
- one for processing, manipulating, searching
- one for receiving external data
- one for viewing

thanks

Offline

 

#2 2018-12-11 11:04:42 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5626

Re: Multiple ASObjC scripts in Xcode Project? What's correct "Structure"

technomorph wrote:

do I still need to add the regular AppDelegate methods to the scripts.
- AppWillFinishLaunching etc?



If you need code run then, yes.

would I want to make the added scripts Delegates of the Main Script?



No. (and by definition, any object can have only one delegate.)

Should I be considering the AppDelegate Applescript as the front end connection between
Cocoa and the rest of my applescript?



That's usually the most straight-forward approach.

IMO, it doesn't make sense to overthink things. You can put stuff that might be called into other class that you init when needed, for example. But by and large, if you come up with a structure of any complexity, chances are you will hit the limitations of AppleScriptObjC.


AppleScriptObjC in Xcode is a good way to put a bit of interface on scripts. It's generally not a good way to try to build full-blown apps.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)