gpt4 book ai didi

ios - 读取存储在 Xcode 项目中的文件

转载 作者:搜寻专家 更新时间:2023-11-01 05:58:39 25 4
gpt4 key购买 nike

这有点难以解释,我希望能够在 iOS 应用程序中读取我计算机上的一些文件。我将文件存储在与我的“ViewController.swift”文件相同的目录中。

enter image description here

我的问题是,如果我想从文件“testData.csv”中读取,我应该如何在我的应用程序中引用它?

最佳答案

试试这个:

let file = NSBundle.mainBundle().pathForResource("testData", ofType: "cvs")
var contents = String(contentsOfFile: path!, encoding: NSUTF8StringEncoding, error: nil)!

关于ios - 读取存储在 Xcode 项目中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31109536/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com