我制作了一个 iphone 应用程序,在其中我从 iTunes 库中获取歌曲并显示在表格中,并将它们存储在我的文档目录中。现在我想把它保密..所以我想从 iTunes 库中删除选定的文件,这样它就不会显示在列表中。谁能帮我做到这一点?代码:
importableDoc = [NSMutableArray array];
// Get public docs dir
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *publicDocumentsDir = [paths objectAtIndex:0];
// Get contents of documents directory
NSError *error;
NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:publicDocumentsDir error:&error];
if (files == nil) {
NSLog(@"Error reading contents of documents directory: %@", [error localizedDescription]);
}
// Add all mp3 files to a list
for (NSString *file in files) {
if ([file.pathExtension compare:@"mp3" options:NSCaseInsensitiveSearch] == NSOrderedSame)
{
NSString *fullPath = [publicDocumentsDir stringByAppendingPathComponent:file];
//NSLog(@"fullPath : %@",fullPath);
[importableDoc addObject:fullPath];
}
}
}