How To Build An AppleScript-Based Cocoa-Application: Difference between revisions

From Wurst-Wasser.net
Jump to navigation Jump to search
No edit summary
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
== Creating a Wikipedia-Application<ref>just like  [[5 Easy Steps To Your First RubyCocoa Application|this]]</ref> ==
== Creating a Wikipedia-Application<ref>just like  [[5 Easy Steps To Your First RubyCocoa Application|this]]</ref> ==
=== Creating the project ===
=== Creating the project ===
I used XCode 3.2.1 on Snow Leopard (10.6) to create this project.
I used XCode 3.2.1 on Snow Leopard (10.6<ref>and this sample will ONLY work with 10.6! You can also do it with 10.5, but synthax is ''slightly'' different.</ref>) to create this project.


==== Choose "New Project…" from File Menu ====
==== Choose "New Project…" from File Menu ====
Line 67: Line 67:


[[Category:AppleScript]]
[[Category:AppleScript]]
[[Category:Development]]

Latest revision as of 19:45, 17 October 2010

This page describes how you can build a simple AppleScript Application using XCode on Snow Leopard (10.6)[1].

Creating a Wikipedia-Application[2]

Creating the project

I used XCode 3.2.1 on Snow Leopard (10.6[3]) to create this project.

Choose "New Project…" from File Menu

AppleScriptCocoaHowTo01.png

Choose "Cocoa-AppleScript Application" from Templates

AppleScriptCocoaHowTo02.png
...and save it somewhere.

Adding a Web View

Add an Outlet

AppleScriptCocoaHowTo03.png
...using this snippet:

property ourWebView : missing value (* This is an outlet to out WebView which we created in Interface Builder *)

Double-Click the Interface-File

AppleScriptCocoaHowTo04.png
AppleScriptCocoaHowTo03a.png
As you can see, the outlet ourWebView is already visible in Interface Builder.

Search for WebView and drag it into your window

AppleScriptCocoaHowTo05.png
AppleScriptCocoaHowTo06.png

Resize the WebView to fill the window

AppleScriptCocoaHowTo07.png

Set Size-Settings for automatic resizing

AppleScriptCocoaHowTo08.png

Connect the Outlet to the WebView

AppleScriptCocoaHowTo09.png

Opening an URL

Tell the WebView to open an URL

Paste this...

tell ourWebView to setMainFrameURL_("http://www.wikipedia.org")

into the method applicationWillFinishLaunching_.
AppleScriptCocoaHowTo10.png

You made it!

Run the app and enjoy!

More

Finetuning

There is some of finetuning that you might want to consider:


  1. This will NOT work on Leopard (10.5), a sample for Leopard will follow later...
  2. just like this
  3. and this sample will ONLY work with 10.6! You can also do it with 10.5, but synthax is slightly different.