Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jules2010

macrumors member
Original poster
Apr 7, 2010
34
0
I just can't get the syntax right..

Code:
+(NSString*)GUIDString {

Thanks in advance.
 
1) It's not a function: it's a class method

2) Pretty simple:

Code:
[NameOfClassThatThisIsDeclaredInButYouChoseNotToTellUs GUIDString];

Replace NameOfClassThatThisIsDeclaredInButYouChoseNotToTellUs with whatever the name of the class (not an instance of the class) is. I would note this is very basic Objective-C. Perhaps some time spent with the documentation would be a good idea?
 
Thanks, I'm using it in the same class so I was just using self.
Now I've tried the name of the function, which worked.
I thought self would have worked thanks.

I have been looking at the documentation and some books I bought, the objective c book isn't quite the same though.
 
Using self would make it an instance method call, since self is an instance. Make sure you understand the difference between class methods and instance methods.

Depends on the context of calling self...if called from within another class method, self refers to the class, not an instance of that class (classes are like instances too).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.