iphone - Show recorded audios in tableview -
i have view responsible recording audio. how can record several audios , show them in table view? i'm trying use docs directory save recorded audios:
nsarray *folders = nssearchpathfordirectoriesindomains(nsdocumentdirectory,nsuserdomainmask, yes); nsstring *documentsfolder = [folders objectatindex:0]; nsstring *recordedaudio = [documentsfolder stringbyappendingpathcomponent:newaudio]; newaudio string contains new audio name typed user suffix .m4a. retrieve saved audios i'm trying this:
nsarray *folders = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsfolder = [folders objectatindex:0]; nsarray *foldercontents = [[nsarray alloc] initwithcontentsoffile:documentsfolder]; i expected foldercontents have audios stored @ documentsfolder load table, count 0. i'm new in docs directory, i'm missing something, or doing wrong.
what wrong, or there way accomplish that?
you getting contents of documents directory incorrectly. right way:
nsarray *foldercontents = [[nsfilemanager defaultmanager] contentsofdirectoryatpath:documentsfolder error:nil];
documents not file, folder.
edit: how save file
assuming have nsdata object such as
nsdata *audiodata = ...; // initialiazed recording
after create recordedaudio string, filename want write (should called audiopath or something), need add this:
[audiodata writetofile:recordedaudio atomically:yes];
Comments
Post a Comment