There are some really wierd things in your code:
imageArray1 = (NSMutableArray *)[[NSFileManager defaultManager] directoryContentsAtPath: fPath];
Here you are casting an NSArray
to a NSMutableArray
, but it will still be an NSArray
. You can't do this.
NSString *location=@"Tops";
NSString *fPath = [documentsDirectory stringByAppendingPathComponent:location];
NSArray *directoryContent = [[NSFileManager defaultManager] directoryContentsAtPath: fPath];
imageArray1 = [directoryContent mutableCopy];
Then you build the fpath
string, which you where already using the first line. Here you are doing the the conversion to NSMutableArray
correctly.
You just need to remove the first line, it is not needed and does nothing. Same goes for this line:
imageArray2 = [[NSMutableArray alloc] init];
You are just create an empty array and then later you just assign an other array:
imageArray2 = [directoryContent mutableCopy];
Just remove the imageArray2 = [[NSMutableArray alloc] init];
it is not necessary and will only use unnecessary memory.
This will work better:
-(void)viewDidLoad
{
[super viewDidLoad];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSFileManager *fileManager = [NSFileManager defaultManager];
//configure carousel
NSString *fPath = [documentsDirectory stringByAppendingPathComponent:@"Tops"];
NSArray *directoryContent = [fileManager directoryContentsAtPath: fPath];
imageArray1 = [directoryContent mutableCopy];
//configure carouse2
fPath = [documentsDirectory stringByAppendingPathComponent:@"Bottoms";];
directoryContent = [fileManager directoryContentsAtPath:fPath];
imageArray2 = [directoryContent mutableCopy];
carousel1.type = iCarouselTypeLinear;
carousel2.type = iCarouselTypeLinear;
}