I'm trying to convert a watchOS 1 app to watchOS 2.
But I saw an error when trying to load an image from an URL with this code:
let url:NSURL = NSURL(string: "http://www.xxxxxxxx.com/xxx/xyz.jpg")!
let data:NSData = try! NSData(contentsOfURL:url, options:[])
imageone.setImage(UIImage(data: data))The error is:
> Error Domain=NSCocoaErrorDomain Code=256 "The file “xyz.jpg” couldn’t be opened." UserInfo={NSURL=http://www.xxxxxxxx.com/xxx/xyz.jpg}
I read on the internet that is because of the new Application Transport Security protocol.
I also read to put
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>in the info.plist on the Watchkit extension but the same error appear.
It's the same also if I use an image in an HTTPS domain.
NOTE: On the simulator it works perfectly!
I'm using XCode 7 beta 5.
Anyone knows how to solve?
Thanks