iOS Developer

iOS Swift decode

2016-05-11  本文已影响445人  云抱住阳光太阳没放弃发亮

以前是这样处理的

let encode = "https%3a%2f%2fitunes.apple.com%2fcn%2fapp%2finks.%2fid1081847121%3fmt%3d8%26v0%3dWWW-GCCN-STAPG-GAMESAPPS-PROMO%26ign-mpt%3duo%253D4"
let decode = incode.stringByReplacingPercentEscapesUsingEncoding(NSUTF8StringEncoding)

到了 Swift 2 中, 上面的方法已经警告废弃,应该采用新的方法。

let encode = "https%3a%2f%2fitunes.apple.com%2fcn%2fapp%2finks.%2fid1081847121%3fmt%3d8%26v0%3dWWW-GCCN-STAPG-GAMESAPPS-PROMO%26ign-mpt%3duo%253D4"
let decode = incode.stringByRemovingPercentEncoding
上一篇下一篇

猜你喜欢

热点阅读