tableview/array の組み合わせを使用してドキュメント ディレクトリからファイルを削除しようとしています。何らかの理由で、NSString
Documents ディレクトリ パスへのポイントが に変換されていますNSCFType
(いくつかの調査の結果、変数が解放されていないために発生していることがわかります)。このため、アプリケーションは行でクラッシュします
NSString *lastPath = [documentsDirectory stringByAppendingPathComponent:temp];
NSCFType
メソッドを認識できないと主張していますstringByAppendingPathComponent
。
誰かが私を助けてくれれば幸いです(これを十分に明確に説明したことを願っています)。
- (void) tableView: (UITableView *) tableView
commitEditingStyle: (UITableViewCellEditingStyle) editingStyle
forRowAtIndexPath: (NSIndexPath *) indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
NSString *temp = [directoryContent objectAtIndex:indexPath.row];
NSLog(temp);
NSString *lastPath = [documentsDirectory stringByAppendingPathComponent:temp];
[[NSFileManager defaultManager] removeItemAtPath:lastPath error:nil];
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
documentsDirectory = [paths objectAtIndex:0];
directoryContent = [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsDirectory error:nil] retain];
//tableview handling below
}