views:

90

answers:

2

Possible Duplicates:
Objective-C: Class vs Instance Methods?
What do the plus and minus signs mean in Objective C next to a method?

I've tried to look around and couldn't come up with a solid answer that really explained my confusion. I've seen a few times and that is a class having a method that has it's "method type" set to "+" ie:

-(Fraction*) fractionWithNumerator: (int) n denominator: (int) d;
now how is that different to
+(Fraction*) fractionWithNumerator: (int) n denominator: (int) d;

+3  A: 

"+" is a method called on the class. "-" is a method called on an instance.

  • +alloc: because you would say [NSString alloc]

  • -init: because you would call init on an instance rather than saying [NSString init]

rchern
All covered in the wonderful Objective-C documentation: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html
bbum
A: 

The difference is one is a class method(+) and the other is an instance method(-). Details

unholysampler