16

我在我的 iOS 应用程序中遇到了一些奇怪的问题。当我的应用程序打开并且用户按下睡眠/唤醒按钮时,应用程序调用

applicationWillResignActive
applicationDidEnterBackground

当用户向右滑动解锁屏幕时,应用程序调用

applicationWillEnterForeground
applicationDidBecomeActive

之后,它会在控制台中打印以下错误:

PBRequester failed with Error Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo=0x1cdfbc00 {NSErrorFailingURLStringKey=https://gsp10-ssl.apple.com/use, NSErrorFailingURLKey=https://gsp10-ssl.apple.com/use, NSLocalizedDescription=A server with the specified hostname could not be found., NSUnderlyingError=0x1cddca10 "A server with the specified hostname could not be found."}

我知道此错误表明未找到指定的主机名。但是哪个主机名?是https://gsp10-ssl.apple.com/use还是我用于 Web 服务的主机名?

如何调试此错误并确定其来源?

4

2 回答 2

2

我有类似的错误。我有一个带有 MKMapView 的应用程序。当我测试应用程序时,我故意断开设备 Wifi 以查看应用程序行为,在调试中我看到错误:

PBRequester failed with Error Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo=0x18e4fac0 {NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorCodeKey=-9806, NSErrorFailingURLStringKey=https://gsp10-ssl.apple.com/use, _kCFStreamErrorDomainKey=3, NSUnderlyingError=0x18e51690 "An SSL error has occurred and a secure connection to the server cannot be made.", NSErrorFailingURLKey=https://gsp10-ssl.apple.com/use}

此时设备正在尝试连接 3G,因为设备启用了“移动数据”。我也没有获得 3G 连接的功劳。我想这是这个错误的具体来源(3G 没有信用),因为当我禁用“移动数据”时,我已经收到另一个错误,也是来自 PBRequester

PBRequester failed with Error Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo=0x188e4b00 {NSErrorFailingURLStringKey=https://gsp10-ssl.apple.com/use, _kCFStreamErrorCodeKey=8, NSErrorFailingURLKey=https://gsp10-ssl.apple.com/use, NSLocalizedDescription=The Internet connection appears to be offline., _kCFStreamErrorDomainKey=12, NSUnderlyingError=0x18d78410 "The Internet connection appears to be offline."}

我倾向于将这些错误归咎于 MKMapView 对象,因为它需要持续的活动连接来检索地图图层/标题。虽然应用程序有其他活动屏幕(没有 MKMapView),但没有引发错误。

于 2014-10-29T11:02:54.440 回答
2

我遇到过同样的问题。我将 parse.com 框架集成到我的应用程序中。

- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
  // Store the deviceToken in the current installation and save it to Parse.
  PFInstallation *currentInstallation = [PFInstallation currentInstallation];
  [currentInstallation setDeviceTokenFromData:deviceToken];
  [currentInstallation saveInBackground];
}

- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
  [PFPush handlePush:userInfo];
}

在我将这两个代码块从 AppDelegate 移动到我的主 ViewController 文件后,错误消息消失了......也许它可以帮助你......

于 2013-04-11T06:54:03.730 回答