私のアプリケーションでは、記録ファイルをドキュメントディレクトリに保存します。その後、これらすべてのファイルをドキュメントディレクトリから取得し、UITableviewがあるMymainClassにこれらすべてのファイルを表示します。このmainClassTableviewの任意の行をクリックすると、このファイルを再生する次のクラスに移動し、このファイルを削除して、Tableviewがあるお気に入りのレコーディングクラスにこのファイルを送信します。次に、再生ボタンアクションメソッドと削除ボタンアクションを実行します。メソッドは正常に機能しますが、このファイルをお気に入りのクラスTableviewに送信する方法がわかりません。ここに、基本的なアイデアを取得するための削除ボタンコードを表示します。
-(IBAction)deleteFile
{
NSArray *dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsDir = [dirPaths objectAtIndex:0];
NSString *documentPath = [docsDir stringByAppendingPathComponent:@"MyRecordings"];
NSString *soundFilePath = [documentPath stringByAppendingPathComponent:fileToPlay];
recordedTmpFile = [NSURL fileURLWithPath:soundFilePath];
[[NSFileManager defaultManager] removeItemAtURL:recordedTmpFile error:nil];
}
[削除]ボタンのコードは、MainTableviewから選択した現在の記録ファイルを削除する方法を示しています。ユーザーが現在の記録ファイルを削除するのではなくお気に入りのクラスのテーブルビューに送信したい場合は、ここで別のドキュメントフォルダーを使用するかどうかを回答します。はいですか?次に、現在のファイル(recordedTmpFile)をこの新しいドキュメントフォルダーに保存する方法を説明します。
-(IBAction)AddToFavourite
{
NSArray *dirPaths1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsDir1 = [dirPaths1 objectAtIndex:0];
NSString *documentPath1 = [docsDir1 stringByAppendingPathComponent:@"MyFovouriteRecordings"];
// How to pass here the Current Recording File (recordedTmpFile) to this new document Folder.
}
NSlogをrecordedTmpFileにすると、結果が表示されます:file:// localhost / Users / Umar / Library / Application%20Support / iPhone%20Simulator / 4.2 / Applications / 9219677A-B0E3-4B78-B2E5-FEA49D689618 / Documents / MyRecordings / 06:Dec: 12_05:54:07%20PM + Active%20song
ヘルプが適用されます。ありがとう