我刚开始使用 Gatsby。我可以使用 Gatsby 的默认启动器,但任何其他启动器似乎都依赖于 Sharp,并且无论我做什么,它的安装都失败了。
info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.6.1/libvips-8.6.1-darwin-x64.tar.gz
/Users/djfriar/Sites/gatsby-pretty/node_modules/sharp/install/libvips.js:76
throw err;
^
Error: self signed certificate in certificate chain
at TLSSocket.onConnectSecure (_tls_wrap.js:1049:34)
at TLSSocket.emit (events.js:182:13)
at TLSSocket._finishInit (_tls_wrap.js:631:8)
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: self signed certificate in certificate chain
gyp ERR! stack at TLSSocket.onConnectSecure (_tls_wrap.js:1049:34)
gyp ERR! stack at TLSSocket.emit (events.js:182:13)
gyp ERR! stack at TLSSocket._finishInit (_tls_wrap.js:631:8)
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" …Run Code Online (Sandbox Code Playgroud) 我正在尝试用 Swift 编写一个 iOS 应用程序,让用户拍照,然后我将在图像上叠加一些额外的数据。我希望图像包含位置数据。我正在使用 AVCapturePhoto,我可以在文档中看到它有一些元数据变量,但我找不到有关如何使用它们的任何信息。当我现在用我的应用拍照时,它的 EXIF 信息中没有位置数据。
如何设置捕获会话以嵌入位置数据?
在我的应用程序中,我目前正在处理托管在网站上的JSON文件.我想这样做,以便如果用户打开应用程序并且没有数据连接,它将使用上次下载的数据.我不完全确定如何解决这个问题.
我最初的想法是下载JSON本身,然后简单地比较加载时的版本号,如果更新则下载它,然后编写应用程序以始终读取本地文件.但是,我想我只是看看网站,在本地存储JSON内容,然后在后续打开时,只需比较版本并更新其本地数据,如果网站上的版本更新.
一种方法优于另一种方法有什么优势吗?
我应该从哪里开始寻找有关制作数据的信息,我从网站托管的JSON加载本地和持久存储?我认为CoreData最适合这个,但我的Google-fu并没有发现如何将JSON带入Core Data.
编辑:
Per Starksy的建议,我在我的应用程序中添加了以下内容,但我收到了错误let jsonData = try ....
func saveJSONFile() {
let itemName = "myJSONFromWeb"
let hostedJSONFile = "http://tourofhonor.com/BonusData.json"
do {
let directory = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor:nil, create:false)
let fileURL = directory.appendingPathComponent(itemName)
// let jsonData = try JSONDecoder().decode(hostedJSONFile.self, from: Data)
let jsonData = try JSONSerialization.jsonObject(with: hostedJSONFile, options: .mutableContainers)
try jsonData.write(to: fileURL, options: .atomic)
//Save the location of your JSON file to UserDefaults
defaults.set(fileURL, forKey: "pathForJSON")
} catch {
print(error)
}
} …Run Code Online (Sandbox Code Playgroud)