简体   繁体   English

Swift无法从parse.com检索图像

[英]Swift can't retrieve images from parse.com

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. 我使用的是Xcode 6.4,它工作正常,但是当我更新到Xcode 7时,似乎查询不适用于照片。

I'm getting username on table view but the images not showing I get this error when testing on simulator iPhone 5: 我在表视图上获取用户名,但未显示图像,但在模拟器iPhone 5上进行测试时出现此错误:

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. 由于不安全,App Transport Security阻止了明文HTTP(http://)资源加载。 Temporary exceptions can be configured via your app's Info.plist file. 可以通过应用程序的Info.plist文件配置临时异常。

And when I test it on iPhone 6 I got this error : 当我在iPhone 6上测试它时,出现此错误:

fatal error: unexpectedly found nil while unwrapping an Optional value 致命错误:解开Optional值时意外发现nil
(lldb) (LLDB)

and showing me a red thread on this line : 并在此行上显示一个红色线程:

query.whereKey("user", equalTo: PFUser.currentUser()!.username!) 

Apple now forcing dev to use ATS(HTTPS), but you can disable it in info.plist by adding this Apple现在强制开发人员使用ATS(HTTPS),但您可以通过添加以下内容在info.plist中将其禁用

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

Should look like this 应该看起来像这样 在此处输入图片说明

Visit Apple docs for more details about ATS and please watch this WWDC video session 访问Apple文档以获取有关ATS的更多详细信息,请观看此WWDC视频会议

Your second issue is explain below 您的第二个问题如下

FPUser.currentUser can return nil if user logged out, and you are using ! 如果用户注销,则FPUser.currentUser可以返回nil,并且您正在使用! 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. 强制解包然后calling username ,因此,如果用户未登录,则currentUser将返回nil,并且最终将在nil上调用username ,因此,您将遇到此崩溃,您应该执行以下操作。

if let user = PFUser.currentUser()
{
   query.whereKey("user", equalTo: user.username!) 
}
else
{
   // show login ui 
}

Apple is now forcing HTTPS connections, that is the App Transport Security message. Apple现在正在强制HTTPS连接,即App Transport Security消息。 You are still sending over clear text HTTP. 您仍通过明文HTTP发送。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM