2

I've seen a few Q&A's here about the same error but none of them was helpful. I'm still getting the same error. What do I need to change? This is what I've got right now.
The error is concerning this line: imageIndex = (imageIndex < 0) ? ([images count] -1):
Thanx for your help!

#import "Photogallery.h"

@interface Photogallery ()


@end

@implementation Photogallery
@synthesize imageView;
int imageIndex = 10;

- (void)viewDidLoad {
[super viewDidLoad];


}
- (IBAction)handleSwipe:(UIGestureRecognizer *)sender {

NSArray *images=[[NSArray alloc]initWithObjects:@"1.jpg",@"2.jpg",@"3.jpg",@"4.jpg",@"5.jpg",@"6.jpg",@"7.jpg",@"8.jpg",@"9.jpg",@"10.jpg", nil];

UISwipeGestureRecognizerDirection direction = [(UISwipeGestureRecognizer *)sender direction];

switch (direction) {
    case UISwipeGestureRecognizerDirectionLeft:
        imageIndex++;
        break;
    case UISwipeGestureRecognizerDirectionRight:
        imageIndex--;
        break;

    default:
        break;
}
imageIndex = (imageIndex < 0) ? ([images count] -1):
imageIndex % [images count];
imageView.image = [UIImage imageNamed:[images objectAtIndex:imageIndex]];
}


@end
Andrey Chernukha
  • 21,488
  • 17
  • 97
  • 161
Max1980
  • 209
  • 2
  • 4
  • 11

1 Answers1

5

use NSInteger, not int, in Objective-C code.

Here is a really good explanation:

When to use NSInteger vs. int

Community
  • 1
  • 1
KirkSpaziani
  • 1,962
  • 12
  • 14