dears
i am using this code
var Locations = [LocationListStats]()
func downloadJSON(completed: @escaping () -> ()) {
let url = URL(string: "http://teslm.net/app/LocationList.php")
URLSession.shared.dataTask(with: url!) { (data, response, error) in
do {
self.Locations = try JSONDecoder().decode([LocationListStats].self, from: data!)
DispatchQueue.main.async {
completed()
}
}catch {
print("JSON Error")
}
}.resume()
}
but i am getting this error : EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
but if i use other URL it working without any error. so do you think i have issue with my code here or i should do something with my Json file at back end ?
error here in this line:
self.Locations = try JSONDecoder().decode([LocationListStats].self, from: data!)
if i print the error it give me this:
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection
i used this in my plist file to try to solve this issue but same thing:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>http://teslm.net/app/LocationList.php</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<true/>
</dict>
</dict>
</dict>
i think this issue is related to HTTPS protocol am i right ?