I declared arrays a,b,c and d as properties in my interface class and initialized them like this:
[self setPatternA:[[NSMutableArray init] initWithArray:@[@0,@0,@1,@1,@2,@2]]];
[self setPatternB:[[NSMutableArray init] initWithArray:@[@3,@4,@4,@5,@5,@3]]];
[self setPatternC:[[NSMutableArray init] initWithArray:@[@3,@3,@4,@4,@5,@5]]];
[self setPatternD:[[NSMutableArray init] initWithArray:@[@0,@1,@1,@2,@2,@0]]];
and now I'm trying to access them like this:
NSInteger a=[patternA objectAtIndex:3];
NSLog(@"pattern a: %ld", (long)a);
but when i print what this returns it isn't the value that I'm expecting. I am also getting a "Incompatible pointer to integer conversion initializing 'NSInteger' (aka 'long') with an expression of type 'id'.
Also, if someone could explain what a 'long' is, that'd be great.
You don't put integers, or
NSInteger
s, into the array, but objects, i.e. instances ofNSNumber
.will give give you correct value.
This is called boxing / unboxing - putting plain values into objects. So what you were dumping was more or less the address of the containing object.