Make a Simple Program With Xcode

Revision as of 00:49, 3 March 2017 by Kipkis (Kipkis | contribs) (importing article from wikihow)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Ever wondered how everyone makes those great programs? Read on to find out how...

Steps

  1. Open Xcode. You may not have Xcode on your system, in that case, install it with the developer tools CD that should have come with your computer.
  2. Click File>new project.
  3. An assistant should open. click "Applescript Application".
  4. Name your project. In this example, it is named "Talking Example".
    • Your project should appear.
  5. Double click "Talking_ExampleAppDelegate.applescript".
  6. Type:
    • on clicked the object
    • (say "hello")
    • end clicked
  7. Then type Command+"B" to build.
  8. Now double click "MainMenu.xib".
    • Interface builder should open.
      • A window should appear.
  9. Drag a button from the palette, double-click it, and name it "Hello".
  10. Now, open the attribute editor by going to "tools" on the menu bar, and clicking the "attribute editor". Then, at the top of the attribute editor, you should see a little white scroll. Click it.
    • QUICK CHECK does your screen look like this?
  11. See the dropdown menu that says "script"? (blue circle) choose "talking example.applescript". Now, see the checkbox that says "action", and under it "clicked"? (red circle) check "clicked". This will make it so that when you click the button, talking example.applescript will activate, thus making it say "hello".
  12. Now click file > save. You may now quit interface builder.
  13. In Xcode, press build and go at the top. Your application should run smoothly.

Snow Leopard and Later

  1. Beginning with Snow Leopard, Apple has deprecated the use of Applescript Studio, but fear not, in spite of a bit of extra typing, things are actually better without it. Go ahead and grab Xcode 3.2.5 or later. You can get 4.0 in the Mac App Store for free.
  2. File>New Project
  3. Click Applescript Application
  4. Name your project, this example is named "Talking Example"
  5. Your project should appear
  6. Double click "Talking_ExampleAppDelegate.applescript"
  7. There are already some items filled in for you. After the property declaration, insert a new handler:
    • on clickedme_(sender)
    • say "hello"
    • end clickedme_
  8. Type Cmd+B to build
  9. Now double-click MainMenu.xib
  10. Interface builder should open. Close any xib windows it brings up from previous projects you may have worked on.
  11. A blank window should appear and you can drag a button onto it from the Library.
  12. Double click the button and make it "Hello"
  13. CTRL-drag from the Hello button to the blue cube called "Talking Example AppDelegate" and let go. You can now pick the clicked-me event handler to link to the "Hello" button you just made.
  14. Now click file > save. You many now quit interface builder.
  15. In Xcode, press build and go at the top. Your application should run smoothly.

Tips

  • you can repeat these steps to create more buttons.

Related Articles