path to main bundle as string

old way was:
set thePath to path of the main bundle as string

trying this as the new way?
set thePath to current application’s class “NSBundle”'s mainBundle (bundlePath)

but its not quite right…can anyone help the newb please.

tell current application's class "NSBundle"
		tell its mainBundle()
			set thePath to its pathForResource_ofType_("fileName", "txt")
		end tell
end tell

Thanks…Ok well that get me the value to the item that im after but then when i try an call it using

do shell script thePath my-exec

it gives an error saying that it cannot make it (thePath) into type string - so i guess I need to make it into a POSIX ?

You need to convert the results to a string but the path is already a posix path.

I’ve been using this for getting bundle path:

set my_path to (current application's class "NSBundle"'s mainBundle()'s bundlePath()) as string
return my_path

or for resources:

set pathToResources to (current application's class "NSBundle"'s mainBundle()'s resourcePath()) as string

Note: “NSBundle”'s has an apostrophe after the double quote (“NSBundle” 's)


Thats Great thanks for your help guys.