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!

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

Edit: Corrected the missing underscore

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?

The pathForResource:ofType: returns a string.

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

The paths → pathsForResources:ofType:inDirectory: returns an array.


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

I’m using this one for path to Resources folder inside app bundle…



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_

Thanks serbian
thats quite handy