ios - declaring directory when using collection View -
i not know how declare directory in .h file. in view controller have written
- (void)viewdidload { [super viewdidload]; // additional setup after loading 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 error saying no visible @ interface for"nsmutablearray" declares selector "addobject".i not know how declare directory called hats in .h file. think use nsmutablearray or don't know sure..
you want use nsmutablearray instead of nsarray. can't alter nsarray after creation.
Comments
Post a Comment