Here's my code:

```
@interface Game : Layer // this is from cocos2d
{
   int maxSprites;
}

@implementation Game
-(void)initVariables
{
  maxSprites = 18;
}

```

Later on, when I print it out,

```
 NSLog(@" maxSprites = %d  ", maxSprites);

```

I get:

```
 maxSprites = 2

```

And operations that require it to be 18, crash or don't work, as if it's really just 2 now.

How would that be possible? =)

`APPLE` + `SHIFT` + `F` reveals no other usage of the `maxSprites` variable.

I've looked at other code examples and often they're exposing the variable with a getter and setter, and they are also using `@property`. Am I missing something? I'm new to Objective-C, so I might as well just be!

EDIT:
hrmph, why'd I get a -1?

Thanks, I will try to learn how to do a Watchpoint.

Until then, I would like to say that I did a `APPLE` + `SHIFT` + `F` for maxSprites" In Project, Textual, Contains, Ignore Case and only resulted in:

```
Game.h:     int maxSprites;
Game.m:     maxSprites = 18;
Game.m:     NSLog(@" maxSprites  = %d", maxSprites);
Game.m:     NSLog(@" maxSprites  = %d", maxSprites);
Game.m:     NSLog(@"maxSprites is at %p", &maxSprites);
Game.m:     NSLog(@"maxSprites is at %p", &maxSprites);
Game.m:     NSLog(@" maxSprites  = %d", maxSprites);
Game.m:     NSLog(@" maxSprites  = %d", maxSprites);
Game.m:     NSLog(@"maxSprites is at %p", &maxSprites);
Game.m:     NSLog(@"maxSprites is at %p", &maxSprites);

```

2nd EDIT:

I found the location where it changes using a watchpoint. It changes here:

```
Expression: “*(int *) 67379960”
New Value: 2
Old  Value: 18

```

On this line:

```
[self checkMatchBarAward:spriteTypeToAdd];

```

Odd? That function doesn't do anything with `maxSprites`. 

EDIT:
-I'm going to make a new question now to find out why the value is changing on its own. Thank you for your help guys, great job.

New post will be taken up here:
[Objective-C: int value changing without cause](https://stackoverflow.com/questions/1941686/objective-c-int-value-changing-without-cause)