Define class methods

Coding Questions, IDE related or anything else

Define class methods

Postby udo.killermann » Fri Jul 16, 2010 6:22 am

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
--------------
MacBook (2GHz, 4 GByte) - Lion (10.7.3)
started Objective Basic coding in April 2010 - still enjoy it ;-)
udo.killermann
 
Posts: 247
Joined: Thu Apr 08, 2010 6:46 am
Location: Hannover, Germany

Re: Define class methods

Postby berndnoetscher » Fri Jul 16, 2010 10:40 am

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
berndnoetscher
Site Admin
 
Posts: 280
Joined: Fri Feb 20, 2009 11:58 am


Return to Objective-Basic (Xcode 3)

Who is online

Users browsing this forum: No registered users and 1 guest

cron