loading nibs

Hey Guys!

I’m trying to get my AS studio app to access the nib of a separate bundle or application, but I’m having trouble with using the load nib command with AS studio. I have no problems loading a nib that is within my app already, but when I try to use the in bundle property with it, I can’t seem to figure out how to work it.

– this is fine
load nib “viewsNib”
set theWindow to window “window1”

– this is annoying
load nib “myNib” in bundle

I don’t know and can’t figure out what to put after bundle. I don’t know how to specify the bundle or what to do. I’ve spent many hours on google :smiley: and drunk heaps of red cordial. I can’t do it. Any ideas?


I’m having this problem too, loading an external nib anyone?

You have to get a little creative and load the bundle using an Obj-C method (this can all be done in AppleScript by way of a “call method” command). Let’s say your nested bundle was named “NestedBundle.bundle” and you’ve added this to the resources of your AS Studio application. When you build the project, this bundle will be included in the main bundle’s resources folder so you can get the path to it easily. Once you have the path, load the bundle, then load the NIB, then show the window:


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

One thing that does get a little tricky is getting the loaded NIB to connect to an AppleScript. What I did was to name the main script in the nested bundle the exact same name as the main script in the main application. Then, when building the bundle, I didn’t include the nested bundle’s script in the AppleScript build phase or in its resources. Then, when everything is built and it is loaded by the main application, since the script it was looking for had the exact same name as the main script’s name, it just uses the main script for its handlers. You can see this in the basic project I mocked up for this here:



So there isn’t any way to have the bundle run its own scripts?

When I used a script within the nested bundle itself, it didn’t work. Not sure why. The solution to use a script with the same name in the application did. It’d be great if someone knew how to make the bundle’s script work, but I don’t have time to spend on it now.