I had the problem of summing two NSInteger, I tried with a simple int, but could not find the answer. I have this in my header file:
@interface ViewController : UIViewController {
NSMutableArray *welcomePhotos;
NSInteger *photoCount;
}
In my runtime, I:
-(void)viewDidLoad{
[super viewDidLoad];
photoCount = 0;
welcomePhotos = [NSMutableArray array];
int sum = photoCount + 1;
NSLog(@"0 + 1 = %i", sum);
}
las NSLog always prints 0 + 1 = 4
Also if do:
if (photoCount < [welcomePhotos count]){
photoCount++;
NSLog(@"%i", photoCount);
}else{
photoCount = 0;
}
Several times I get: 4, 8, 12 .
So this is a four pass, but I can’t understand why.
source
share