title: Using enum types as properties in Objective C
body: <p>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:</p>
  
  <pre><code>typedef enum  {
      Open,
      Unavailable,
      Unknown
  } LocationStatus;
  
  @interface Location : NSObject {
  
      LocationStatus status;
  }
  
  @property (nonatomic) LocationStatus status;
  
  @end
  </code></pre>
  
  <p>and an implementation that looks like this:</p>
  
  <pre><code>@implementation Location
  
  @synthesize status;
  
  @end
  </code></pre>
  
  <p>At some point in the code, I'm setting the value like this:</p>
  
  <pre><code>location1.status = Open;
  </code></pre>
  
  <p>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).</p>
  
  <p>Later on in the code, I attempt to read that property like this:</p>
  
  <pre><code>LocationStatus status = location.status;
  </code></pre>
  
  <p>At this point in the code, the debugger is able to evaluate all the properties of my class correctly, except <code>Status</code>, 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.</p>
  
  <p>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.</p>