I'm a veteran .NET developer making my first foray into Objective C programming. I'm having difficulty with a property of an enum type. Some context... I have an class header and enum like this:
typedef enum {
Open,
Unavailable,
Unknown
} LocationStatus;
@interface Location : NSObject {
LocationStatus status;
}
@property (nonatomic) LocationStatus status;
@end
and an implementation that looks like this:
@implementation Location
@synthesize status;
@end
At some point in the code, I'm setting the value like this:
location1.status = Open;
The debugger then evaluates this as having the correct value, and it is resolving to the correct enum (note also that there are other properties not shown here... they too evaluate properly).
Later on in the code, I attempt to read that property like this:
LocationStatus status = location.status;
At this point in the code, the debugger is able to evaluate all the properties of my class correctly, except Status
, which shows a memory address, but not an actual value. When the execution reaches this line, I consistently get a EXC_BAD_ACCESS error in the console, and the app crashes.
I'm pretty sure this reflects a fundamental misunderstanding on my part on how to use properties and enums in Objective C (and probably C in general). If anyone could shed some light on this, I'd be most grateful.