A crash course in Objective-c for Matt

What you write in C++
object->memberfunction(arg1, arg2, arg3);
is in objective-c
[object memberfunction:arg1 name-of-arg2:arg2 name-of-arg3:arg3];
(thus arguments, except the 1st one, have names)
and is declared by a prototype written:
@interface class-name : parent-class-name {
class local variables;
}
- (return-type)memberfunction:(arg1-type)arg1-dummy  
name-of-arg2:(arg2-type)arg2-dummy
                name-of-arg3:(arg3-type)arg3-dummy;
@end

and this stuff can, as in C++, return a value or not return anything.

All MAC OS defined class names begin by NS, and the subclasses I have defined 
by FL.

There is also the syntax:
[classname memberfunction:arg1 name-of-arg2:arg2]
that corresponds to a static member function:
classname::memberfunction(arg1, arg2)
and that normally returns an instance of this class (i.e., a class *)

One tends to imbricate things:
[[NSEvent alloc] initWithData:data]
reads, in C++:
NSEvent *retval = NSEvent::alloc();
retval->initWithData(data);

With this, you can read most of objective-c !

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to