Page 1 of 1

Define class methods

PostPosted: Fri Jul 16, 2010 6:22 am
by udo.killermann
Hi Bernd,

how would I define a class method +(NSString *)helloWorld in Objective Basic. I didn't find an example or documentation on this. It would be handy to have this mechanism.

Kind regards
Udo

Re: Define class methods

PostPosted: Fri Jul 16, 2010 10:40 am
by berndnoetscher
udo.killermann wrote:Hi Bernd,

how would I define a class method +(NSString *)helloWorld in Objective Basic. I didn't find an example or documentation on this. It would be handy to have this mechanism.

Kind regards
Udo


Udo,

Objb don't support it with a "static" keyword like in other languages, because some people got mixed up, when it was there in the first release of objb in 2006.

A solution is to use the singleton pattern, objb supports.

+ define a sub or function (and mark it with a comment as class only function for yourself) - make it public
+ use it with CLASSNAME.sub only

Hope it helps.
If not please let me know.

CU
Bernd