0

Possible Duplicate:
What do the plus and minus signs mean in Objective C next to a method?

I was confused between -(type) and +(type) in class.

@interface Class:Something{

    +(id) foo;
    -(void) fooAgain;
}

+(type) is class level function ( according to google) but I don't understand the meaning of class level function. Inside +(id)foo is kind of {return some value} I think it is similar to getter or setter but somehow it must be different. (because @property refers to getter/setter)

Can anybody explain simply? Thanks

Community
  • 1
  • 1
WondererInAsh
  • 57
  • 2
  • 8

1 Answers1

4

Class methods should be called using the class name itself. And, the instance methods should be called using instances of the class.

So, you have to call the above methods from some other classes, like the following,

The class method:

[Something foo]; // Correct
[Something fooAgain]; // Crash

The instance method:

Something *aThing = [[Something alloc] init];
[aThing fooAgain]; // Correct
[aThing foo]; // Crash
EmptyStack
  • 51,274
  • 23
  • 147
  • 178