Reputation: 10979
In myObject.h
:
typedef enum {
GET,
POST
} HTTPMethods;
And then inside the @interface
definition, a property:
@property (nonatomic) HTTPMethods *httpMethod;
In myClass.m
, I have the #import
of myObject.h
and then:
myObject *obj = [[myObject alloc] init];
obj.httpMethod = POST;
This seems to work, but the compiler yells at me:
`Incompatible integer to pointer conversion assigning to 'HTTPMethods *' from 'int'.
Where am I going wrong here?
Upvotes: 3
Views: 1092
Reputation: 717
There's a big hint in the error message!
In C and Objective C, an enum is a user defined data type. You've written HTTPMethods *, which means "a pointer to an enum", whereas it looks like you just wanted an enum.
So change your property to this:
@property (nonatomic) HTTPMethods httpMethod;
For more info, google "C pointers" and you'll find information like this: http://pw1.netcom.com/~tjensen/ptr/pointers.htm
Upvotes: 0
Reputation: 28419
An enum is a built-in type, and not an object. As such, you probably want to store the integral value itself and not a pointer.
@property (nonatomic, assign) HTTPMethods httpMethod;
Upvotes: 7