运行以下代码时,我在Xcode控制台上遇到错误:
// Create session
NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration ephemeralSessionConfiguration]];
// Create request
NSURL *url = [NSURL URLWithString:@"https://my.backend.com/endpoint"];
NSMutableURLRequest *mutableRequest = [NSMutableURLRequest requestWithURL:url];
mutableRequest.HTTPMethod = @"POST";
[mutableRequest setValue:@"text/plain" forHTTPHeaderField:@"Content-Type"];
NSData *postBody = [@"my_string_payload" dataUsingEncoding:NSUTF8StringEncoding];
[mutableRequest setHTTPBody:postBody];
// Create and initiate task
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:mutableRequest];
[dataTask resume];我得到的错误如下:
... [Common] _BSMachError: port c11b; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"
... [Common] _BSMachError: port c11b; (os/kern) invalid name (0xf) "Unable to deallocate send right"运行resume方法时显示错误。不过,一切似乎都很好,没有崩溃,请求也按预期工作。
我一直在寻找这个错误消息,通常发现它与1)奇怪的Xcode问题(如this)或2) UI元素生命周期(如here)有关。不过,这些似乎并不适用于这种情况。
我使用的是Xcode 8.3.3。
发布于 2017-06-28 18:04:45
我刚刚意识到这个错误只有在使用断点运行时才会出现。当我在没有断点的情况下运行这一节时,请求仍然按预期工作,并且控制台中没有错误,所以这看起来只是在调试有断点的NSURLSessionDataTask时才会出现问题。
https://stackoverflow.com/questions/44799286
复制相似问题