I have not bundle the application yet since I’m still developing it.
I tried different things following your steps but with no success.
When I drag the .txt into the project folder I’m prompt to select a
[format]‘Destination’: Copy items if needed (I check it)
‘Added folders’: (I check Create folder references)
‘Add to targets’: (I check my project)[/format]
And here it is the code I’ve used in the AppDelegate file to test it:
set theFile to current application's NSBundle's mainBundle()'s pathForResource:"MyFile" ofType:"txt"
display dialog theFile
# It yields "msng"
set theFile to theFile as «class furl»
set theFileList to paragraphs of (read theFile as «class utf8»)
# But I received the following error message:
Can’t make missing value into type «class furl». (error -1700)[/AppleScript]
Thank you in advance.
If you have an AppleScriptobjc Xcode project you do have a bundle.
Don’t check Create folder references. Delete the file and the enclosing folder (in Xcode) and add the file again.
Of course “MyFile” must match the file name in the bundle. And use the Cocoa API to read the file
property |⌘| : a reference to current application
set filePath to |⌘|'s NSBundle's mainBundle()'s pathForResource:"MyFile" ofType:"txt"
set theText to (|⌘|'s NSString's stringWithContentsOfFile:filePath encoding:(|⌘|'s NSUTF8StringEncoding) |error|:(missing value)) as text
set theParagraphs to paragraphs of theText
When I started my project, it was only based in vanilla AppleScript and then I realized that at least a basic knowledge of Object C and now COCOA API is necessary to go ahead with the features I want to have my app.
Tomorrow is a day off for me, so I will be digging in into the ‘Everyday AppleScriptObjC 3ed’ I’ve just get.