ios - 在应用程序文档目录中查找文件

标签 ios swift

我已经使用 iexplorer 在我安装的应用程序文档目录中复制了一个视频文件,我试图通过访问该视频在 avplayer 上播放它。但我找不到该视频。这是我的代码,用于在应用程序文档目录下查找文件

var paths: [AnyObject] = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
var documentsDirectory: String = paths[0] as! String
    do {
    let filePathsArray: [AnyObject] = try NSFileManager.defaultManager().subpathsOfDirectoryAtPath(documentsDirectory)
    print("files array %@", filePathsArray)
    }catch {

    }

显示为空

最佳答案

来自苹果文档:

subpathsOfDirectoryAtPath:error:

Performs a deep enumeration of the specified directory and returns the paths of all of the contained subdirectories.

尝试迭代 .contentsOfDirectoryAtPath:error

关于ios - 在应用程序文档目录中查找文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37882541/

相关文章:

ios - 在 UIwebView 应用程序中使用 Facebook 登录

ios - Swift - 类型 '*' 不符合协议(protocol) '*'

ios - 无法更改状态栏样式

ios - 在后台运行完成后,如何使用来自 parse.com 查询的数据填充 UITableView?

ios - 很快,有没有办法让 UIView 类也成为 MPMediaPickerControllerDelegate?

ios - 如何修复 iOS 11 和 macOS V10.12 Safari 上损坏的 transform-origin?

ios - Swift 中可测试的异步设计模式

ios - 使用 swift 使用带有 azure 服务的自定义 api 插入

ios - 如何将 Storyboard UISearchBar 连接到以编程方式创建的 UISearchController?

iOS- swift : How to write generic function for this case?