title: NSDictionary With Integer Values
body: <p>I'm working on a game with monsters. Each one has a list of stats that are all going to be ints. I can set up each stat as it's own variable but I'd prefer to keep them in an NSDictionary since they are all related. I'm running into a problem when I'm trying to change the value's of each stat.</p>
  
  <p><strong>What I Have:</strong> </p>
  
  <pre><code>-(id) init {
      self = [super init];
      if(self) {
          stats = [NSDictionary dictionaryWithObjectsAndKeys:
                @"Attack",  0,
                @"Defense", 0,
                @"Special Attack", 0,
                @"Special Defense", 0,
                @"HP", 0, nil];
      }
      return self;
  }
  </code></pre>
  
  <p><strong>What I want to do</strong></p>
  
  <pre><code>-(void) levelUp {
      self.level++;
      [self.stats objectForKey:@"Attack"] += (level * 5);
      [self.stats objectForKey:@"Defense"] += (level * 5);
      [self.stats objectForKey:@"Special Attack"] += (level * 5);
      [self.stats objectForKey:@"Special Defense"] += (level * 5);
      [self.stats objectForKey:@"HP"] += (level * 5);
  }
  </code></pre>
  
  <p><strong>Error I'm Getting</strong></p>
  
  <pre><code>Arithmetic on pointer to interface 'id', which is not a constant size in non-fragile ABI
  </code></pre>
  
  <p>So it seems obvious to me that the reason I'm getting the problem is that I'm getting an object returned from objectForKey instead of an integer. So I tried to do the intValue method on the object I'm getting but that gave me another error, specifically: </p>
  
  <pre><code>Assigning to 'readonly' return result of an objective-c message not allowed
  </code></pre>
  
  <p>I'm out of ideas for how to fix this. Any help? Would it be better to just give up the idea to store them all together and just use an int property for each stat?</p>