Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148a Safari/6533.18.5)
Hello again, i am experiencing a few problems using 'typedef enum' statement. i would like to define variable types which will be used through out the program , so i thought i should put the definition in the header file. It all compiles ok and appeared to be going well,but when i step through into my implementation file i notice the variables lose their values?. Should the typedef be repeated in the implementation file as well?. Below is my header file and main file.
Hello again, i am experiencing a few problems using 'typedef enum' statement. i would like to define variable types which will be used through out the program , so i thought i should put the definition in the header file. It all compiles ok and appeared to be going well,but when i step through into my implementation file i notice the variables lose their values?. Should the typedef be repeated in the implementation file as well?. Below is my header file and main file.
Code:
#import <Foundation/Foundation.h>
typedef enum cardFace { ace=1,two=2,three=3,four=4,five=5,six=6,
seven=7,eight=8,nine=9,ten=10,jack=10,
queen=10,king=10} suite;
typedef enum suite {spades=1,diamonds=2,clubs=3,hearts=4} cardFace;
@interface Card : NSObject {
suite varSuite;
cardFace varFace;
}
-(void) setCard: (cardFace) vF of : (suite) vS;
@end
#import <Foundation/Foundation.h>
#import "Card.h"
//enum flag {cross,circle};
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
Card* Card1 =[[ Card alloc] init ] ;
[Card1 setCard:three of:diamonds];
[pool drain];
return 0;
}
Last edited by a moderator: