title: Fetching an Integer From CoreData?
body: <p>I have fetched a result from core data in my app and need to get the integer value of its 'capacity' attribute I gave it.</p>
  
  <p>The 'capacity' attribute is an NSInteger 16 in my core data model.</p>
  
  <p>I get my result like so:</p>
  
  <pre><code>entity = [NSEntityDescription entityForName:@"TableInfo" inManagedObjectContext:appDelegate.managedObjectContext];
      [fetchRequest setEntity:entity];
      [fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"name == %@", [NSString stringWithFormat:@"%@", [tablesArray objectAtIndex:row]]]];
  
      NSArray *selectedTableFetched = [appDelegate.managedObjectContext executeFetchRequest:fetchRequest error:&amp;error];
  </code></pre>
  
  <p>Now my problem is how do I get the 'capacity' value from my result? I know there is a result as I have check the count of the array and I have tried this:</p>
  
  <pre><code>NSNumber *n = [selectedTableFetched valueForKey:@"capacity"];
  </code></pre>
  
  <p>It gives me something, when accessing the NSNumber I get a meaningless long number, so if I try and access the integer value like so:</p>
  
  <pre><code>[n integerValue]
  </code></pre>
  
  <p>it crashes the app and I get this error:</p>
  
  <pre><code>'NSInvalidArgumentException', reason: '-[__NSArrayI integerValue]: unrecognized selector sent to instance 0x138870'
  </code></pre>
  
  <p>All I need to do is get that integer value from the capacity attribute.</p>