iDevGames Forums
Adding Member Variables to Classes - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Programming Languages & Scripting (/forum-8.html)
+--- Thread: Adding Member Variables to Classes (/thread-2834.html)



Adding Member Variables to Classes - FlamingHairball - Jan 12, 2008 02:00 PM

As you all know, I have been going through BeyondCloisters FlipSquare Tutorial, and have come to a part that I don't quite understand. What does it mean to add a Member Variable to a class? The instructions are posted below.

"Open Cell.h and add the following member variable to the Cell class:

int owner; // cell owner"

and this is what I typed in…


Code:
#import <Cocoa/Cocoa.h>

int owner; // cell owner
@interface Cell:NSObject {



- (void)setOwner;
- (int)owner;

}

@end

I am now getting a "parse error before "-" token" error. Can anyone tell me what went wrong?


Adding Member Variables to Classes - Terrydil - Jan 12, 2008 02:37 PM

When working on the interface only the variables, not the methods, should go between the {}
So it should be more like this:

Code:
#import <Cocoa/Cocoa.h>


@interface Cell:NSObject {

int owner;

}

- (void)setOwner;
- (int)owner;


@end



Adding Member Variables to Classes - FlamingHairball - Jan 12, 2008 02:43 PM

Ah, works like a charm. Thanks a lot!!Smile