草庐IT

NSFileManager

全部标签

ios - 访问文件属性与访问 sqlite 记录

在我们的一个应用程序中,我被要求记录图像的最后修改日期。这样我就可以检查服务器是否某个图像已更改并相应地更新我的缓存。我的第一个方法是访问文件属性并进行比较,但网上的一些地方提到了延迟方面的严重瓶颈。我的第二个选择是创建一个SQLite表来管理它。(使用fmdb)我决定编写一个简单的延迟测试。在下一个测试中,我将访问500个文件属性和500个sqlite记录:-(void)latencyTest{NSMutableArray*arrayTest1=[[NSMutableArrayalloc]init];NSMutableArray*arrayTest2=[[NSMutableArray

ios - 访问文件属性与访问 sqlite 记录

在我们的一个应用程序中,我被要求记录图像的最后修改日期。这样我就可以检查服务器是否某个图像已更改并相应地更新我的缓存。我的第一个方法是访问文件属性并进行比较,但网上的一些地方提到了延迟方面的严重瓶颈。我的第二个选择是创建一个SQLite表来管理它。(使用fmdb)我决定编写一个简单的延迟测试。在下一个测试中,我将访问500个文件属性和500个sqlite记录:-(void)latencyTest{NSMutableArray*arrayTest1=[[NSMutableArrayalloc]init];NSMutableArray*arrayTest2=[[NSMutableArray

ios - 写入文本文件(附加)时,我写入的最后一个值将替换所有以前的值

我正在尝试将我的SQLite3表重现为保存到电话文档中的.csv文件。为了做到这一点,我尝试在文件末尾追加一个新行,每次在我的数组中找到一个对象时,这都有效-但是它似乎一遍又一遍地重现最后一行我的sql表中的确切行数。这是SQLiteSelect查询:NSMutableArray*allGPS=[[NSMutableArrayalloc]init];GPS*gps=[[GPSalloc]init];//OpenthedatabasefromtheusersfilessytemNSArray*paths=NSSearchPathForDirectoriesInDomains(NSDocu

ios - 写入文本文件(附加)时,我写入的最后一个值将替换所有以前的值

我正在尝试将我的SQLite3表重现为保存到电话文档中的.csv文件。为了做到这一点,我尝试在文件末尾追加一个新行,每次在我的数组中找到一个对象时,这都有效-但是它似乎一遍又一遍地重现最后一行我的sql表中的确切行数。这是SQLiteSelect查询:NSMutableArray*allGPS=[[NSMutableArrayalloc]init];GPS*gps=[[GPSalloc]init];//OpenthedatabasefromtheusersfilessytemNSArray*paths=NSSearchPathForDirectoriesInDomains(NSDocu

swift - 从项目特定路径获取资源 URL

我需要通过从项目目录(又名mainBundle)开始的路径检索我的Xcode项目中包含的资源的URL因此,如果我指定的路径是./snd/archer/acknowledge1.wav,我需要从中创建一个URL。我知道我可以对系统目录使用NSURL(fileURLWithPath:),但我不知道如何直接从包中执行此操作。 最佳答案 从Swift3开始,答案是:Bundle.main.url(forResource:"acknowledge1",withExtension:"wav",subdirectory:"snd/archer")

swift - 从项目特定路径获取资源 URL

我需要通过从项目目录(又名mainBundle)开始的路径检索我的Xcode项目中包含的资源的URL因此,如果我指定的路径是./snd/archer/acknowledge1.wav,我需要从中创建一个URL。我知道我可以对系统目录使用NSURL(fileURLWithPath:),但我不知道如何直接从包中执行此操作。 最佳答案 从Swift3开始,答案是:Bundle.main.url(forResource:"acknowledge1",withExtension:"wav",subdirectory:"snd/archer")

ios - 将文件保存在swift 3的文档目录中?

我使用以下代码将文件保存在swift3的文档目录中:fileManager=FileManager.default//letdocumentDirectory=fileManager?.urls(for:.documentDirectory,in:.userDomainMask).firstasStringvarpath=NSSearchPathForDirectoriesInDomains(.documentDirectory,.userDomainMask,true)[0]asStringpath=path+nameletimage=#imageLiteral(resourceNa

ios - 将文件保存在swift 3的文档目录中?

我使用以下代码将文件保存在swift3的文档目录中:fileManager=FileManager.default//letdocumentDirectory=fileManager?.urls(for:.documentDirectory,in:.userDomainMask).firstasStringvarpath=NSSearchPathForDirectoriesInDomains(.documentDirectory,.userDomainMask,true)[0]asStringpath=path+nameletimage=#imageLiteral(resourceNa

swift - iOS9 Swift 文件创建 NSFileManager.createDirectoryAtPath 与 NSURL

在iOS9之前,我们已经创建了这样一个目录letdocumentsPath=NSSearchPathForDirectoriesInDomains(.DocumentDirectory,.UserDomainMask,true)[0]as!StringletlogsPath=documentsPath.stringByAppendingPathComponent("logs")leterrorPointer=NSErrorPointer()NSFileManager.defaultManager().createDirectoryAtPath(logsPath,withIntermed

swift - iOS9 Swift 文件创建 NSFileManager.createDirectoryAtPath 与 NSURL

在iOS9之前,我们已经创建了这样一个目录letdocumentsPath=NSSearchPathForDirectoriesInDomains(.DocumentDirectory,.UserDomainMask,true)[0]as!StringletlogsPath=documentsPath.stringByAppendingPathComponent("logs")leterrorPointer=NSErrorPointer()NSFileManager.defaultManager().createDirectoryAtPath(logsPath,withIntermed