I have the apple script below in xcode and it doesn’t run the same as it does in apple script. I am having this trouble a lot does xcode applescript objc not run the same as apple script?
XCODE
-- FormAppDelegate.applescript
-- Form
--
-- Created blah blah
-- Copyright blah blah
--
script FormAppDelegate
property parent : class "NSObject"
on awakeFromNib()
set WebsiteHtml to do shell script "curl [url=http://macscripter.net/]http://macscripter.net/"[/url]
display dialog WebsiteHtml
set text item delimiters to "head"
display dialog text item 1 of WebsiteHtml
end awakeFromNib
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
end applicationWillFinishLaunching_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate_
end script
APPLE SCRIPT
set WebsiteHtml to do shell script "curl [url=http://macscripter.net/]http://macscripter.net/"[/url]
display dialog WebsiteHtml
set text item delimiters to "head"
display dialog text item 1 of WebsiteHtml
How do I know how to make sure to tell it to use apple script and NSObject?
I have a code like this too that errors because it checks the items of NSObject
on ClickHere_(sender)
tell application "Finder"
set iitems to get name of items of alias "Macintosh HD:users:nicholassmith:Desktop"
set itemOne to text item 1 of iitems
display dialog itemOne
end tell
ItemOneDesktop's setStringValue_("hi")
end ClickHere_
First, don’t use finder for standalone applications. You don’t need it in this case and you don’t want to be depended on other applications. Then when you’re working with lists you can’t say text item but just access the item directly.
--applescript way
on ClickHere_(sender)
set iitems to list folder "Macintosh HD:users:nicholassmith:Desktop" as list
set itemOne to item 1 of iitems
display dialog itemOne
ItemOneDesktop's setStringValue_("hi")
end ClickHere_