-1
我有一个URL是这样的:我需要保存的URL参数与斯威夫特
let myURL = http://localhost/#access_token=12312312.1231231.31321
我需要“12312312.1231231.31321”从URL。我试过用componentsSeparatedByString,但我没有得到我所需要的。你的问题
我有一个URL是这样的:我需要保存的URL参数与斯威夫特
let myURL = http://localhost/#access_token=12312312.1231231.31321
我需要“12312312.1231231.31321”从URL。我试过用componentsSeparatedByString,但我没有得到我所需要的。你的问题
来看,其实只是你使用componentsSeparatedByString
let myURL = "http://localhost/#access_token=12312312.1231231.31321"
let strings = myURL.components(separatedBy: "=")
print(strings[1]) //strings[1] will give you the "12312312.1231231.31321"
componentsSeparatedByString
将返回由"="
在这种情况下,分隔字符串数组有提及。
让我看看你的代码 –
http://stackoverflow.com/questions/30759158/using-the-split-function-in-swift-2 – Sahil