gpt4 book ai didi

ios - swift/https : NSURLSession/NSURLConnection HTTP load failed

转载 作者:可可西里 更新时间:2023-11-01 03:06:53 25 4
gpt4 key购买 nike

不幸的是,今天早上我的 XCode 更新到了版本 7,而我使用 http 开发的 iOS 应用程序现在需要 https。因此,按照许多教程,我配置了我的 MAMP 服务器,以便使用 https/ssl 创建一个虚拟证书。现在在我的 iOS 应用程序中,URL 如下所示:

static var webServerLoginURL = "https://localhost:443/excogitoweb/mobile/loginM.php"
static var webServerGetUserTasks = "https://localhost:443/excogitoweb/mobile/handleTasks.php"
static var webServerGetUsers = "https://localhost:443/excogitoweb/mobile/handleUsers.php"
static var webServerGetProjects = "https://localhost:443/excogitoweb/mobile/handleProjects.php"

如果我尝试在我的浏览器中访问它们,它们工作正常。我曾经使用 NSURLSession.sharedSession().dataTaskWithRequest() 访问数据库和 php 文件,这现在引发了标题错误。例如,这是引发错误的行:

if let responseJSON: [[String: String]] = (try? NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions())) as? [[String: String]] {
...
}

这是完整的错误信息:

2015-09-21 16:41:48.354 ExcogitoWeb[75200:476213] CFNetwork SSLHandshake failed (-9824)
2015-09-21 16:41:48.355 ExcogitoWeb[75200:476213] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9824)
fatal error: unexpectedly found nil while unwrapping an Optional value

我想知道如何解决这个问题。我在这里阅读了一些有用的答案,但还有很多事情我仍然不明白,如果有人愿意帮助/解释我,我将不胜感激。

最佳答案

将此添加到您应用的 Info.plist

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

关于ios - swift/https : NSURLSession/NSURLConnection HTTP load failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32698165/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com