Using enums in Objective C -
i have declared enum in .h file.
in event.h file
typedef enum eventtype { movementstart = 100019, movementstop = 100020, heartbeat = 100021 } eventtype;
i have imported event.h viewcontroller , trying use as:
eventtype eventtype; nsarray *eventtypes = [nsarray arraywithobjects:eventtype.movementstart, nil];
this giving me error: member reference base type 'eventtype' (aka 'enum eventtype') not structure or union.
how fix ?
first off, reference enum value, wouldn't type eventtype.movementstart
, should type movementstart
.
second, eventtype
enum values integers, can store objects in nsarray
, wouldn't work anyway. store replacing eventtype.movementstart
[nsnumber numberwithinteger:movementstart]
, or less verbose, @(movementstart)
.
Comments
Post a Comment