declaring directory when using collection View
I do not know how to declare your directory in the .h file. In my View
Controller I have written
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSArray *allImagesArray = [[NSArray alloc ]init];
NSArray *paths =
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *location=@"Hats";
NSString *fPath = [documentsDirectory
stringByAppendingPathComponent:location];
NSArray *directoryContent = [[NSFileManager defaultManager]
directoryContentsAtPath: fPath];
for(NSString *str in directoryContent){
NSString *finalFilePath = [fPath stringByAppendingPathComponent:str];
NSData *data = [NSData dataWithContentsOfFile:finalFilePath];
if(data)
{
UIImage *image = [UIImage imageWithData:data];
[allImagesArray addObject:image];
}}}
however of course I get an error saying no visible at interface
for"NSMutableArray" declares the selector "addObject".I do not know how to
declare my directory called Hats in the .h file. I think you use
NSMutableArray or something but I don't know for sure..
No comments:
Post a Comment