Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 4. Creating an Xcode Project > Creating Sandbox Applications

4.7. Creating Sandbox Applications

When experimenting with code, a sandbox application can be very useful. Follow these steps to quickly create a simple Cocoa application that can be used to exercise code, or even as the foundation for a full-fledged application:

  1. Create a new project using the Cocoa Application template.

  2. Turn on garbage collection in the build settings.

  3. Add a new class to the project. This is your test class.

  4. Add an action to the class. An action is a method that takes a single object identifier as its sole parameter and returns an IBAction, as in - (IBAction)doSomething:(id)sender. IBAction is synonymous with void, so the action doesn't actually return anything. The sender parameter will be the object that sent the action (the button or menu item defined in step 8). It's often ignored.

  5. Add your test code to the action method.

  6. Open the MainMenu NIB document.

  7. Create an instance of your test class in the NIB document.

  8. Add a button to the window or a new menu item to a menu.

  9. Select the button or menu item and connect its Sent Action to the action method defined in step 4. Do this by dragging the Sent Action connector to your test object, releasing the mouse button, and then choosing the action.


You are currently reading a PREVIEW of this book.


Get instant access to over $1 million worth of books and videos.


Start a Free Trial

  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint