美文网首页
swift 向沙盒写日志

swift 向沙盒写日志

作者: 秋叶红90 | 来源:发表于2021-10-12 09:35 被阅读0次
guard let rootPath = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.cachesDirectory, FileManager.SearchPathDomainMask.userDomainMask, true).first else {
            return
        }
        let dir = "\(rootPath)/Test"
        let filePath = "\(dir)/hjj.txt"
        if !FileManager.default.fileExists(atPath: dir) {
            try? FileManager.default.createDirectory(atPath: dir, withIntermediateDirectories: true, attributes: nil)
        }
        if !FileManager.default.fileExists(atPath: filePath) {
            let isSuc = FileManager.default.createFile(atPath: filePath, contents: nil, attributes: nil)
            print("cg == \(isSuc)")
        }
        print("filePath == \(filePath)")
        if let handle = FileHandle.init(forWritingAtPath: filePath) {
            defer{
                handle.closeFile()
            }
            let test = "\(Date.init()): test === \n"
            handle.seekToEndOfFile()
            if let data = test.data(using: String.Encoding.utf8) {
                handle.write(data)
            }
            
        }

相关文章

  • swift 向沙盒写日志

  • 沙盒 文件

    沙盒SandBox 向沙盒写文件和读文件 文件管理NSFileManager 图片下载 创建文件夹 创建文件 复制...

  • iOS沙盒管理工具FHHSandBoxViewer

    KeyWord:沙盒文件递归遍历、Swift里的闭包多个weak修饰、iOS使用AirDrop iOS沙盒查看器F...

  • iOS 沙盒文件增删

    图片 写入 沙盒 删除沙盒里的文件 向沙盒里 写入文件夹,并向文件夹里 写入东西 得到沙盒文件夹 下的所有文件 来...

  • swift 获取沙盒路径

    1.Home 目录.整个应用程序所在目录 依据路径寻找过去,模拟器目录下内容如下沙盒目录 真机目录寻找参考这里 2...

  • xcode导出沙盒日志

  • iOS C++ dump PCM

    swift 获取沙盒路径 Ref: 1.Iphone文件读写操作2.NULL when using fopen w...

  • IOS沙盒 - OC

    沙盒: 沙盒包含: 沙盒路径获取的方法:

  • Objective-C沙盒结构

    导读: 一、什么是沙盒机制二、沙盒的特点三、沙盒的结构组成四、获取沙盒目录路径 一、什么是沙盒机制 iOS中的沙盒...

  • iOS数据存储之应用程序沙盒

    应用程序沙盒 iOS应用程序只能在系统为该应用所分配的文件区域下读/写文件,这个文件区域就是沙盒.沙盒机制:一种安...

网友评论

      本文标题:swift 向沙盒写日志

      本文链接:https://www.haomeiwen.com/subject/suqroltx.html