iOS Swift decode

作者: 云抱住阳光太阳没放弃发亮 | 来源:发表于2016-05-11 10:39 被阅读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
    

    相关文章

      网友评论

        本文标题:iOS Swift decode

        本文链接:https://www.haomeiwen.com/subject/lxxurttx.html