Reputation: 209
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
Upvotes: 2
Views: 10037
Reputation: 1972
use NSInteger, not int, in Objective-C code.
Here is a really good explanation:
Upvotes: 5