title: Objective-C handling integer values
body: <p>I am getting confused with how to handle Integers in Objective C.</p>
  
  <p>If I define the following:</p>
  
  <pre><code>NSInteger i = 6;
  NSLog(@"%d", i);
  </code></pre>
  
  <p>I expect it to print 6 to the console.</p>
  
  <p>however I have an NSInteger within an object which is obviously reference by a pointer so I get very difference results.</p>
  
  <p>For example:</p>
  
  <pre><code>@interface Section : NSObject {
  NSInteger Id;
  }
  
  @property (nonatomic, assign) NSInteger Id;
  </code></pre>
  
  <p>Please assume this has been synthesized in the implementation.</p>
  
  <p>I create the object set its value and access it again as follows:</p>
  
  <pre><code>Section *section = [[Section alloc] init];
  section.Id = 6;
  
  NSMutableArray *sections = [[NSMutableArray alloc] init];
  [sections addobject:section];
  
  Section *sectionB = [setions objectAtIndex:0];
  NSLog(@"%d",  sectionB.Id);
  </code></pre>
  
  <p>This has the strange effect of printing the memory address ie a number like 5447889. Why can I not just get the value?</p>
  
  <p>I have tried using:</p>
  
  <pre><code>NSInteger sid = [[section Id]integerValue];
  </code></pre>
  
  <p>But I then get the warning <strong>Invalid receiver type 'NSInteger'</strong> and sometime get an error <strong>Program received signal:  “EXC_BAD_ACCESS”.</strong></p>
  
  <p>I would really like to know how to handle Integers, or any values for that matter properly.</p>
  
  <p>Many Thanks</p>