博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
NSFileManager_写入数据(默认创建文件)
阅读量:7234 次
发布时间:2019-06-29

本文共 1009 字,大约阅读时间需要 3 分钟。

import UIKitclass ViewController: UIViewController {    override func viewDidLoad() {        super.viewDidLoad()                var documentsPath:String = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true).first!        documentsPath = documentsPath.stringByAppendingString("/video.mov")        print("\(documentsPath)")                let nsdata:NSData = NSData(contentsOfURL:NSURL(string: "http://api.k780.com:88/?app=qr.get&data=test&level=L&size=6")!)!        do {                        try nsdata.writeToFile(documentsPath, options: .AtomicWrite)        }catch{                        print("写入失败")        }                if DirectoryExistAtPath(documentsPath) {            print("file Exist")        }else {            print("file notExist!")        }    }    func DirectoryExistAtPath(path:String)->Bool {        return NSFileManager.defaultManager().fileExistsAtPath(path)    }

 

转载于:https://www.cnblogs.com/karling/p/5127043.html

你可能感兴趣的文章
Linux存储管理及硬盘分区、格式化、挂载
查看>>
Linux服务器时间不准确
查看>>
【AD】清楚windows下的不同凭据缓存
查看>>
没有如果,只需要去尝试
查看>>
LINUX下删除用户与主目录
查看>>
Remote Listener Server side Connect-Time Load Balancing
查看>>
程序开发时编写sql语句的注意事项
查看>>
Oracle 12c新特性对于业务上的一些影响总结
查看>>
Xenserver HA功能配置文档
查看>>
lamp+rsyslog+loganalyzer的安装配置
查看>>
通联数据是如何使用Docker+Rancher构建自动发布管道的?
查看>>
c#调用cxf的代码
查看>>
Linux下openssh升级安装配置
查看>>
用python操作mysql数据库(之数据查询结果返回字典类型)
查看>>
activemq升级报错
查看>>
python 实现(简单的一个购物商城小程序)
查看>>
算法学习之路|微博转发抽奖
查看>>
MySQL 新特性应用JSON
查看>>
python操作mysql(一)MySQLdb模块安装和数据库基本操作
查看>>
centos7最小化安装需要安装软件
查看>>