Tengo una clase People que contiene varios bits de sobre una persona. Me gustaría poder identificar qué tipo de persona es esta, así que pensé en usar una enumeración tipodef para esto porque ya lo había visto antes y parece ser la solución más limpia. Pero, no estoy seguro de cómo declarar esto, luego convertirlo en una propiedad.Uso de un typedef enum en mi objeto Clase
.h
typedef enum {
kPersonTypeFaculty,
kPersonTypeStaff,
kPersonTypeSearch
} personType;
@interface Person : NSObject {
NSString *nameFirst;
NSString *nameLast;
NSString *email;
NSString *phone;
NSString *room;
NSString *status;
NSString *building;
NSString *department;
NSString *imageURL;
NSString *degree;
NSString *position;
NSString *bio;
NSString *education;
}
@property (nonatomic, retain) NSString *nameFirst;
@property (nonatomic, retain) NSString *nameLast;
@property (nonatomic, retain) NSString *email;
@property (nonatomic, retain) NSString *phone;
@property (nonatomic, retain) NSString *room;
@property (nonatomic, retain) NSString *status;
@property (nonatomic, retain) NSString *building;
@property (nonatomic, retain) NSString *department;
@property (nonatomic, retain) NSString *imageURL;
@property (nonatomic, retain) NSString *degree;
@property (nonatomic, retain) NSString *position;
@property (nonatomic, retain) NSString *bio;
@property (nonatomic, retain) NSString *education;
@end
.m
#import "Person.h"
@implementation Person
@synthesize nameFirst, nameLast, email, phone, room, status, building, department, imageURL, degree, position, bio, education;
- (void)dealloc {
[nameFirst release];
[nameLast release];
[email release];
[phone release];
[room release];
[status release];
[building release];
[department release];
[imageURL release];
[degree release];
[position release];
[bio release];
[education release];
[super dealloc];
}
@end
Quiero ser capaz de hacer algo como:
Person *person = [[[Person alloc] init] autorelease];
person.nameFirst = @"Steve";
person.nameLast = @"Johnson";
person.personType = kPersonTypeStaff;
me estoy perdiendo una parte crucial de esta idea?
¡Pavor, tan fácil! ¡Gracias! –