0

I was using 6.4 of Xcode and it was working fine but when I updated to Xcode 7 it seems like query isn't working for photos.

I'm getting username on table view but the images not showing I get this error when testing on simulator iPhone 5:

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.

And when I test it on iPhone 6 I got this error :

fatal error: unexpectedly found nil while unwrapping an Optional value
(lldb)

and showing me a red thread on this line :

query.whereKey("user", equalTo: PFUser.currentUser()!.username!) 
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Salah
  • 933
  • 3
  • 13
  • 32
  • related http://stackoverflow.com/questions/32495059 related http://stackoverflow.com/questions/32775234 – Fattie Sep 25 '15 at 15:20

2 Answers2

4

Apple now forcing dev to use ATS(HTTPS), but you can disable it in info.plist by adding this

<key>NSAppTransportSecurity</key>  
     <dict>  
          <key>NSAllowsArbitraryLoads</key><true/>  
     </dict>

Should look like this enter image description here

Visit Apple docs for more details about ATS and please watch this WWDC video session

Your second issue is explain below

FPUser.currentUser can return nil if user logged out, and you are using ! force unwrapping and then calling username, so if user is not logged in then currentUser will return nil and you will end up calling username on nil, hence you are getting this crash, you should do something like this.

if let user = PFUser.currentUser()
{
   query.whereKey("user", equalTo: user.username!) 
}
else
{
   // show login ui 
}
Adnan Aftab
  • 14,377
  • 4
  • 45
  • 54
0

Apple is now forcing HTTPS connections, that is the App Transport Security message. You are still sending over clear text HTTP.

Darko
  • 9,655
  • 9
  • 36
  • 48