【问题标题】:Find specific character from URL Link从 URL 链接中查找特定字符
【发布时间】:2018-03-28 07:31:02
【问题描述】:

如何使用 Swift 3 从 URL 字符串变量中找出特定字符?

我想从 URLlink(图片已给出) user_lati,user_long,destination_lat,destinaton_long 中获取值并保存。

谁能给我解决方案?

【问题讨论】:

  • 你能给我正确的解释吗?
  • 我上面链接的另一个问题向您展示了如何从 URL 获取这些值
  • 请正确阅读我的问题,我的要求不同,你的答案完全不同
  • 您想查找 的位置?角色?

标签: swift string url double latitude-longitude


【解决方案1】:

我在下面给出了几个例子。你真的应该检查StringURLCollections的文档

let urlString = "https://www.example.com/search?q=test&user=john"
let url = URL(string: urlString)!

print(url.query) // q=test&user=john
print(urlString.index(of: "?")?.encodedOffset) // 30 - index of ?
print(url.absoluteString.index(of: "?")?.encodedOffset) // same as above

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-19
    • 2017-09-04
    • 2021-11-05
    • 2015-12-03
    • 1970-01-01
    相关资源
    最近更新 更多