在做一個(gè)網(wǎng)絡(luò)應(yīng)用時(shí),解析json時(shí)報(bào)錯(cuò) App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file. fatal error: unexpectedly found nil while unwrapping an Optional value
報(bào)錯(cuò)原因是xcode禁止明文http傳輸.通過(guò)修改info.plist可解決:
- 添加App Transport Security Settings,類型是Dictionary
- 在App Transport Security Settings添加Allow Arbitrary Loads,類型是Boolean,值是YES
不過(guò)從蘋果官方目前發(fā)布出來(lái)的消息上看铆帽, 在 2017 年一月份開(kāi)始委刘,就不再允許開(kāi)發(fā)者打開(kāi) NSAllowsArbitraryLoads 設(shè)置了场勤。