Xcode 升級到7.3beta版后,做http的網(wǎng)絡(luò)訪問的時(shí)候會報(bào)錯(cuò):
error------ Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.}
網(wǎng)絡(luò)搜索之后才知道,Xcode9引入了新特性ATS,要求app訪問的網(wǎng)絡(luò)必須使用HTTPS協(xié)議。如果想要繼續(xù)訪問http網(wǎng)頁,需要在info.plist文件中添加NSAppTransportSecurity關(guān)鍵字,其類型為Dictionary,在它下面添加NSAllowsArbitraryLoads類型Boolean,值設(shè)為YES。這樣就可以接著訪問http網(wǎng)頁啦~~