I am using multiple iCarousels and want to import pictures from the directory. I have iCarousel 1 on top and have iCarousel 2 on the bottom. I have about 6 folders in the directory in the iOS device where the user has taken pictures. I want to assign the iCarousel 1 to directory "apple" and iCarousel 2 to directory "green".
The below is my code until now. However of course, this gets an error saying "Redefinition of..." since I am setting paths for 2 imageArrays. How should I make this code simpler?
Furthermore, I also have a warning saying 'NSMutableArray *_strong' from 'NSArray *_strong'
at the imageArray2 = directoryContent;
line. I really want to make this all working.
- (void)viewDidLoad
{
[super viewDidLoad];
//configure carousel
imageArray1 = (NSMutableArray *)[[NSFileManagerdefaultManager] directoryContentsAtPath: fPath];
NSString *location=@"apple";
NSString *fPath = [documentsDirectory stringByAppendingPathComponent:location];
NSArray *directoryContent = [[NSFileManager defaultManager] directoryContentsAtPath: fPath];
imageArray1 = directoryContent;
imageArray2 = [[NSMutableArray alloc] init];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *location=@"green";
NSString *fPath = [documentsDirectory stringByAppendingPathComponent:location];
NSArray * directoryContent = [[NSFileManager defaultManager] directoryContentsAtPath: fPath];
imageArray2 = directoryContent;
carousel1.type = iCarouselTypeLinear;
carousel2.type = iCarouselTypeLinear;
}
You're declaring some variables twice.
you can do something like this: