Joy Online Manual
NAME |
@class - Create a new Objective-C class |
SYNOPSIS |
@class class-name [: superclass-name] [<protocol1, protocol2, ...>] [{
[@private | @protected | @public]
struct-declaration-list
[@private | @protected | @public]
struct-declaration-list
...
}]
[-|+][(type)] method-selector [declaration-list] {
statements
}
[-|+][(type)] method-selector [declaration-list] {
statements
}
...
@end
@class class-name1, class-name2, ...;
DESCRIPTION |
Adds a new class to the Objective-C run-time environment. The new class inherits all the methods and instance variables from its superclass and may add its own instance variables and methods. You can either implement the methods in the @class statement, or add them later using @teach.
If you specify protocols, Joy will check for each one if the class correctly implements it. If so, the protocol will be added to the class' protocol list, otherwise an error will be reported. You declare instance variables exactly as you do in Objective-C. The visibility specifications @private, @protected, and @public are allowed, but ignored. For compatibility with Objective-C, adding new classes using @interface and @implementation is also supported. If the class already exists, a warning message will be reported, and the redefinition will be ignored. You can also use @class to forward-declare identifiers as Objective-C class names, so the type class-name * will be correctly parsed as an id type though Joy has not yet seen a class definition for it. |
EXAMPLE |
@class Rectangle : NSObject {
float width, height;
BOOL filled;
NSColor *fillColor;
}
@end
SEE ALSO |
@interface
@implementation
@teach
Index |