Page 2 of 2

Re: Fun building on top of JavaScript (Objective-J)

Posted: Thu Dec 18, 2008 4:13 pm
by Chris Corbyn
Oh, and before you start pulling hairs out wondering why the most elementary stuff in ObjC isn't working in ObjJ, these two basic structures from ObjC:

Code: Select all

@interface MyClass : NSObject
{
}
 
- (void)aMethod:(NSString *)str;
 
@end
And

Code: Select all

@implementation MyClass
{
}
 
- (void)aMethod:(NSString *)str
{
  ... implementation here ...
}
 
@end
They only exist as a direct @implementation in ObjJ. You just don't need the header file with a @interface, all you need is a single .j file. It's just that JavaScript is less long-winded than C.

Code: Select all

@implementation MyClass : CPObject
{
}
 
- (void)aMethod:(CPString)str
{
  ... implementation here ...
}
 
@end
Other things that don't exist in ObjJ (yet):

* Protocols - I've requested it. Protocols are basically what we think of as interfaces in PHP/Java.
* Delcared properties do exist, but slightly differently using @accessors.
* Fast enumeration - JS already took that syntax :(