★ TouchArcade needs your help. Click here to support us on Patreon.

Obj-C / Cocoa

04-20-2011, 12:09 AM
Joined: Dec 2009
Location: California
Posts: 448
Send a message via AIM to jwei44
Obj-C / Cocoa

I recently purchased a book and it went good until I reached the memory management section of the book.

If anyone could possibly (minimally) explain + or - class/class methods.

- (float)circumferenceFromRadius:(float)radius;
Or even something like that...

Well, if you can help, let me know and I'll ask some questions.
04-20-2011, 06:36 AM
Joined: Aug 2009
Location: Argentina
Posts: 264
If they start with + they are class methods. You call them like this:
[ClassName methodName];
If they start with - they are instance methods. You need an object of that class:
ClassName* instance = [ClassName new];
[instance methodName];
I hope that helps.

Mariano Ruggiero // Follow me on Twitter (@ArtCoder) // Check out our games:
NEW! Elemental Rage - metroidvania-style adventure platformer
Silent Swords // Silent Swords ZERO // Crunchy Planets
04-20-2011, 07:46 AM
Joined: Mar 2009
Location: Singapore
Posts: 1,770
Send a message via AIM to kohjingyu
For instance methods it can also be called like

ClassName *className = [[ClassName alloc] init];
[className callMethod];
[className release];
That's personally what I use - it's just more natural for me
04-20-2011, 07:15 PM
Joined: Mar 2011
Posts: 137
And the way for iOS.
But for a release direct after a call/or more autorelease is easier to type.