In class1 I create an object of class2. I then use a method on this object to set its NSMutableArray
-(void) cloneArray: (NSMutableArray *) array{
pictures = [NSMutableArray arrayWithArray:array];
}
Class2 is a ViewController which has a UIImageView.
I present the class2 object after creating it. This class then has its own methods which display the next image when a swipe is detected.
-(void) nextImageSelector{
if (counter == [pictures count]-1) {
counter = 1;
asset = [pictures objectAtIndex:counter];
ALAssetRepresentation *assetRepresentation = [asset defaultRepresentation];
UIImage *fullScreenImage = [UIImage imageWithCGImage:[assetRepresentation fullScreenImage] scale:[assetRepresentation scale] orientation:[assetRepresentation orientation]];
photo.image = fullScreenImage;
}
The app crashes when calling the line
if (counter == [pictures count]-1)
So I think it is crashing because the array is created for an object and then the next array is trying to be checked is for the class instance itself.
How can I fix this so that I can copy an array for this class2 to use in its own methods like the nextImageSelector?