I would want to show the image to from the directory. In the directory I have made folders to store the pictures. I am getting an error that is saying Use of undeclared identifier 'NSFileManagerdefaultManager' and Use of undeclared identifier 'documentsDirectory'; did you mean 'NSDocumentDirectory'? and Bad receiver type 'NSUInteger' (aka 'unsigned int'). I can not get rid of this. I am trying but it just doesn't work.
-(void)viewDidLoad
{
[super viewDidLoad];
//configure carousel
imageArray1 = (NSMutableArray *)[[NSFileManager defaultManager] directoryContentsAtPath: fPath];
NSString *location=@"Tops";
NSString *fPath = [documentsDirectory stringByAppendingPathComponent:location];
NSArray *directoryContent = [[NSFileManager defaultManager] directoryContentsAtPath: fPath];
imageArray1 = [directoryContent mutableCopy];
imageArray2 = [[NSMutableArray alloc] init];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
location=@"Bottoms";
fPath = [documentsDirectory stringByAppendingPathComponent:location];
directoryContent = [[NSFileManager defaultManager] directoryContentsAtPath: fPath];
imageArray2 = [directoryContent mutableCopy];
carousel1.type = iCarouselTypeLinear;
carousel2.type = iCarouselTypeLinear;
}
There are some really wierd things in your code:
Here you are casting an
NSArray
to aNSMutableArray
, but it will still be anNSArray
. You can't do this.Then you build the
fpath
string, which you where already using the first line. Here you are doing the the conversion toNSMutableArray
correctly.You just need to remove the first line, it is not needed and does nothing. Same goes for this line:
You are just create an empty array and then later you just assign an other array:
Just remove the
imageArray2 = [[NSMutableArray alloc] init];
it is not necessary and will only use unnecessary memory.This will work better: