Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
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:
Create a new project using the Cocoa Application template.
Turn on garbage collection in the build settings.
Add a new class to the project. This is your test class.
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.
Add your test code to the action method.
Open the MainMenu NIB document.
Create an instance of your test class in the NIB document.
Add a button to the window or a new menu item to a menu.
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.