Tuesday, December 12, 2017

#1 2009-10-01 09:29:08 am

Harald
Member
Registered: 2006-06-12
Posts: 4

path to me

It seems that the path to me command does not really work anymore in AppleScriptObjC.

Anybody know how to get that to work now?

Thanks!

Offline

 

#2 2009-10-01 09:45:58 am

Craig Williams
Administrator
From:: Ft. Smith, AR
Registered: 2006-12-07
Posts: 888

Re: path to me

Applescript:

tell class "NSBundle" of current application
           set theItem to its mainBundle's pathsForResource_ofType_("ItemName", "ItemType")
end tell

Edit: Corrected the missing underscore


Filed under: NSBundle

Offline

 

#3 2009-10-02 05:46:47 am

Harald
Member
Registered: 2006-06-12
Posts: 4

Re: path to me

Thanks!

After reading the documentation (http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Reference/Foundation/Classes/NSBundle_Class/Reference/Reference.html#//apple_ref/occ/clm/NSBundle/pathsForResourcesOfType:inDirectory:)

I guess it is:

set theItem to its mainBundle's pathForResource_ofType_("ItemName", "ItemType")

instead of

set theItem to its mainBundle's pathsForResource_ofType_("ItemName", "ItemType")

Still I end up getting back an NSDictionary, right?
Can I browse that like a list then?

Last edited by Harald (2009-10-02 06:39:41 am)

Offline

 

#4 2009-10-02 11:55:53 am

Craig Williams
Administrator
From:: Ft. Smith, AR
Registered: 2006-12-07
Posts: 888

Re: path to me

The pathForResource:ofType: returns a string.

Applescript:

- (NSString *)pathForResource:(NSString *)name ofType:(NSString *)extension

The paths -> pathsForResources:ofType:inDirectory: returns an array.

Applescript:


- (NSArray *)pathsForResourcesOfType:(NSString *)extension inDirectory:(NSString *)subpath

The return type is what is at the beginning of the line; (NSString *), (NSArray *), etc. If it were a dictionary
it would have (NSDictionary *) there instead.

Offline

 

#5 2009-10-03 04:25:05 pm

serbian
Member
Registered: 2009-09-07
Posts: 1

Re: path to me

I'm using this one for path to Resources folder inside app bundle..

Applescript:



property pathToMe : "NSString"

---------

on applicationWillFinishLaunching_(aNotification)
       tell current application's class "NSBundle"
           tell its mainBundle()
               set pathToMe to resourcePath() as string
           end tell
       end tell
   end applicationWillFinishLaunching_

Last edited by serbian (2009-10-05 08:04:22 pm)

Offline

 

#6 2009-10-05 05:57:58 am

Harald
Member
Registered: 2006-06-12
Posts: 4

Re: path to me

Thanks serbian
thats quite handy

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)