gpt4 book ai didi

ios - URL(fileURLWithPath : Bundle. main.path(forResource : "ports", ofType : "geojson")!) 为零?

转载 作者:行者123 更新时间:2023-11-28 10:05:19 26 4
gpt4 key购买 nike

当我在应用程序中运行该行时,下面的行返回 nil(从而使应用程序崩溃)。这行代码来自mapboxes example here关于分组。

let url = URL(fileURLWithPath: Bundle.main.path(forResource: "ports", ofType: "geojson")!)

我实现了他们建议添加的这个链接:link并将其添加到项目中,如下所示: enter image description here

我做错了什么,我该如何解决?

最佳答案

如果这样

Bundle.main.path(forResource: "ports", ofType: "geojson")!

崩溃这意味着你需要检查这个文件的目标成员资格

用于跟踪

if let file = Bundle.main.path(forResource: "ports", ofType: "geojson") {
let url = URL(fileURLWithPath:file)
}
else {
print("Not exists")
}

所以选择文件并勾选

enter image description here

关于ios - URL(fileURLWithPath : Bundle. main.path(forResource : "ports", ofType : "geojson")!) 为零?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54818223/

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