Note: This describes the full CocoaBasic version
Getting Started with CocoaBasic
The Project Window
There is a Main Project window called "Project Browser" as shown here.
It is separated into two parts with tables (lists) with three columns
each:
- Classes List - shows Class name, its Superclass and the Bundle
(i.e. group of classes and resources) it was loaded from
- Instances List - shows Instance name, Class and Instance group
(NIB-file)
If you don't have much experience with object oriented programming yet,
think of the classes as structured data types (records, structs) with
associated functions and operators (called methods) and the instances
as pre-initialized variables of a one of these structured data type.
The following actions are possible in the main window:
- If you select a class in the Class browser, the Instances will be
sorted and the first Instance of this class will be selected.
- If you select an Instance, the class will be selected as well.
- If you click into the title (Class, Superclass, Bundle, Instance,
Class, Group) the table is sorted according to the selected column.
- If you double click a Class in the Superclass column, the
Superclass will be selected.
- If you double click a Class in the Class name column, the Class
Editor will open.
- If you double click an Instance (in either column) the Instance
editor will open. For Windows, the Window Editor will open. For Menus,
the Menu Editor will open. To open the Instance Editor for Windows or
Menus, either select Edit/Edit Instance from the Edit menu or hold the
alt key pressed while double clicking.
- You can select a Filter for the Class bundle.
Creating Instances
To create objects (Instances) of a certain type, select the type
(class) in the leftmost column. Then, select File/New Instance from the
File Menu. This will automatically add a new Instance to the Instance
list.
Then double-click into the new Instance and the Instance Editor opens.
Creating Windows
A Window is simply a predefined Instance of the Class "NSWindow"
together with its NSViews. You can create a new window with the File/New
Window menu. In this case, the Window Editor opens.
If you later on want to edit the Window in the standard Instance
Editor, press the alt key while double-clicking.
Creating and Editing Instances
Description forthcoming.
Creating and Editing Subclasses
Description forthcoming.
In object oriented programming, you can define your own data types by
extending existing classes. A new subclass inherits all properties and
methods from its superclass.
A Hello World example
- First, start CocoaBasic. This will open a fresh project.
- Select File/New Window. A new Window will appear.
- Scroll the Class Browser until you can see the NS??? entry.
Select this entry and drag it to the window. There it will change into a
text field. Additionally, a new instance is created.
- Either select the instance in the Instance Browser, or the object
in the Window and double click. This will open the Instance Editor.
- Locate the Property "????". Click into the Value column. There,
you can now enter and edit the contents.
- Save the project (File/Save or apple-S). A selection dialog
appears where you can select the project name. Keep the file suffix
(.ccbas).
- Select File/Build Application. A Build dialog appears. Enter the
application name "HelloWorld" and press the Build button.
- After this, you will find the HelloWorld application in the same
folder (directory) as you have saved the project file.
- Double click in the Finder on the HelloWorld application and
voila, it opens.
- You may also open the Preferences Pane and check "create
Application in Applications folder". Then, you will find the HelloWorld
application in your private Applications folder.
How it compares to Project and Interface Builder
Basically, CocoaBasic combines the functionality of both, project
builder and interface builder into a single application. Classes are
initialized with all classes that are contained in the Cocoa Framework,
classes loaded from Plugins. The user-defined classes are stored in the
CocoaBasic project file.
What happens when building an application
When building an application,
- The project is saved if not alredy done.
- All user-defined methods are compiled.
- An application bundle is created.
- The Info.plist file
is created.
- The application icon is stored into the resources.
- The runtime executable is copied into the bundle.
- All user-defined classes and methods are stored in the bundle for
execution by the runtime executable.
- All Instances are stored in .nib-files
as defined by the Instance Groups.
- All Resources are copied into the application.
- The Help files are stored into the bundle.
- Plugins added to CocoaBasic are copied into the bundle.
Last Change: 11 Mar 2003 - ©hns@dsitri.de, 2003