2012-03-01 103 views
0

我設置我的網址與記錄:設置記錄的NSDocumentDirectory url?

NSArray *dirPaths; 
NSString *docsDir; 

dirPaths = NSSearchPathForDirectoriesInDomains(
               NSDocumentDirectory, NSUserDomainMask, YES); 
docsDir = [dirPaths objectAtIndex:[globals sharedGlobals].folderCounter]; 
NSString *soundFilePath = [docsDir 
          stringByAppendingPathComponent:@"sound1.caf"]; 

NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath]; 

[globals sharedGlobals].folderCounter爲0時開始,它的工作原理。 接下來的時間我記錄我做它在另一個指標:

[globals sharedGlobals].folderCounter=[globals sharedGlobals].folderCounter+1; 

所以在接下來的時間我試圖記錄我得到錯誤:

index 1 beyond bounds [0 .. 0] 

但爲什麼不能我創建一個新的地方錄音?我想有4個文件夾1-2-3-4,並且每次錄製另一個文件夾。

我該怎麼做?

謝謝。

回答

1

返回的數組在索引0處只有一個條目。我想你想要的是獲取文檔目錄路徑並追加一個文件名 - 然後保存到$ docdir/filenameN.caf。你應該索引文件名,如file1.caf file2.caf。

您示例中的索引可以保持爲0.您也可以考慮爲汽車文件1st創建子文件夾。