2016-08-22 100 views
4

此代碼之前:字符串(contentsOfURL :)斯威夫特3

if let resultOfURL = try? String(contentsOfURL:myURL!, encoding: String.Encoding.utf8) { 

現在拋出這個錯誤:

'init' has been renamed to 'init(describing:)' 

任何幫助嗎?非常感謝!!

+3

幫助自己:重新輸入'字符串(',並期待在代碼完成建議正確的語法 – vadian

+0

字符串(說明:)爲完成一項建議,但我不知道如何創建一個主題,代表一個帶有編碼的URL,我還看到contentsOf:/ contentsOfURL的完成建議只是通過contentsOf去除了錯誤,但並沒有爲這個調用引入「描述」我沒有想過要試試這個,會用contentsOf進行測試:現在... – RanLearns

回答

9

the Swift 3 Migration Guide

Users may need to manually migrate calls to String(contentsOfURL:usedEncoding:) to String(contentsOf:usedEncoding:)

+0

鏈接的獎勵點數,我應該已經打開了,現在將會我的第一個地方是用任何Swift - > Swift 3古怪進行搜索。 – RanLearns