隐式转换失去整数精度:'unsigned long' 到 'int' - 错误

Max*_*980 2 cocoa-touch objective-c uikit ios

我在这里看到了一些关于相同错误的问答,但没有一个有帮助。我仍然遇到同样的错误。我需要改变什么?这就是我现在所拥有的。
错误与这一行有关: imageIndex = (imageIndex < 0) ? ([图像数] -1):
感谢您的帮助!

#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
Run Code Online (Sandbox Code Playgroud)

Kir*_*ani 5

在 Objective-C 代码中使用 NSInteger,而不是 int。

这是一个非常好的解释:

何时使用 NSInteger 与 int