iOS 9 - NSURLConnection在设备上失败(模拟器工作)

时间:2015-10-07 05:36:22

标签: https nsurlconnection ios9

我在使用NSURLConnection的iOS9应用程序中遇到问题。我使用以下编码来调用https服务:

[NSURLConnection sendSynchronousRequest:request
                      returningResponse:&response
                                  error:&error];

我收到错误,显示以下消息:

_kCFStreamErrorDomainKey=1, NSUnderlyingError=0x15e55be0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "The Internet connection appears to be offline."

我已将我的域名添加到info.plist文件中。

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>sub.mydomain.at</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <false/>
                <key>NSExceptionMinimumTLSVersion</key>
                <string>TLSv1.2</string>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <true/>
                <key>NSIncludesSubdomains</key>
                <false/>
                <key>NSRequiresCertificateTransparency</key>
                <false/>
                <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
                <false/>
                <key>NSThirdPartyExceptionMinimumTLSVersion</key>
                <string>TLSv1.2</string>
                <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                <true/>
            </dict>
        </dict>
    </dict>

你有提示我为什么会失败吗?令我对模拟器的惊喜一切正常。

谢谢!

0 个答案:

没有答案