2016-09-27 4 views
-1

와 함께 URL 매개 변수를 저장해야합니다나는 다음과 같은 URL을 가지고 스위프트

let myURL = http://localhost/#access_token=12312312.1231231.31321 

은 그 URL에서 "12312312.1231231.31321"를 취할 필요가있다. componentsSeparatedByString을 시도했지만 필요한 정보를 얻지 못했습니다.

+0

코드 표시 –

+2

http://stackoverflow.com/questions/30759158/using-the-split-function-in-swift-2 – Sahil

답변

0

질문을 보면, 당신은 당신이 경우 "="로 구분되는 문자열의 배열을 반환합니다 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를 사용하여 언급이 단지 정말로이다.

관련 문제