8

当我使用以下代码时,出现错误消息:

[NSURLConnection sendAsynchronousRequest:request queue:myQueue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
        NSLog(@"response status code: %ld, error status : %@", (long)[httpResponse statusCode], error.description);

        if ((long)[httpResponse statusCode] >= 200 && (long)[httpResponse statusCode]< 400)
            {
               // do stuff
                [self requestFunction]; //Web Service
            }
}];

错误信息:

2017-02-27 01:13:30.088641 RENAULT[210:12313] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-02-27 01:13:30.090449 RENAULT[210:12313] [MC] Reading from public effective user settings.

[self requestFunction] 函数启动一个简单的请求:

        NSMutableURLRequest* request = [[NSMutableURLRequest alloc] init];
        NSString *url_string = [bytes stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
        [request setURL:[NSURL URLWithString:[set_send_order stringByAppendingString: url_string]]];
        [request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
        [request setTimeoutInterval:timeOut];
        [NSURLConnection connectionWithRequest:request delegate:self]; 

我确切地说没有调用connectionDidFinishLoading:,但是如果我在没有sendAsynchronousRequest:的情况下直接启动它,它就可以工作。那么为什么我使用 sendAsynchronousRequest: 函数的事实让我出现了两条错误消息,以及 connectionDidFinishLoading 的错误调用?

先感谢您。

4

2 回答 2

27

它发生在我身上。当我使用 textField 时,控制台中的相同日志。以下是我的操作:

  • 从 Xcode 菜单打开:产品 > 方案 > 编辑方案
  • 在您的环境变量中设置 OS_ACTIVITY_MODE 在值集禁用

由于这个讨论,我解决了它。

于 2017-03-10T03:31:47.360 回答
1

如果应用程序尝试使用键盘让用户输入内容时发生。(如触摸UITextField,输入密码......)可能是XCode模拟器的键盘有问题。关闭模拟器并重新启动它可以得到很好的结果。

于 2021-08-25T07:41:39.390 回答