Reputation: 31323
I have my constants and custom enums in a separate .h file. The file is a subclass of NSObject
.
typedef NS_ENUM(NSInteger, MyEnumName) {
EnumValueOne,
EnumValueTwo
};
In another class which is also a subclass of NSObject
, I have a property for said enum.
@property (assign, nonatomic) MyEnumName hello;
And inside its implementation file, I'm trying to set its value like so,
self.hello = EnumValueTwo;
But I get an error at that line saying,
No setter method 'setHello:' for assignment to property
I tried declaring a setter method manually for that property but it still didn't work.
If I do the same inside a view controller, it works fine. Cannot do that in the NSObject
subclass.
Can someone tell me why this is and how to correct it?
Thank you.
Upvotes: 1
Views: 4019
Reputation: 10828
in the example project you try to call self in a class method.. this is you r problem not the enum. you can't access self or any instance variable from a class method.
Upvotes: 2