gpt4 book ai didi

ios - AFNetworking 和 -[__NSCFBoolean 长度] : unrecognized selector sent to instance 0x1f54358

转载 作者:行者123 更新时间:2023-11-28 22:12:12 24 4
gpt4 key购买 nike

我有几天遇到这个奇怪的问题 2014-03-24 16:50:56.097 MyApp[1610:4703] -[__NSCFBoolean length]: unrecognized selector sent to instance 0x1f54358

我调试了我的库,这是一个静态库,我将其打包为 .framework 并分发给开发人员。

在断点处调试有点困难,所以我将静态库 .xcodeproj 文件添加到示例客户端应用程序并尝试使用它。经过一些研究并试图找出发生这种情况的位置后,我没有其他理由相信这是一个 AFNetworking 问题!

我的静态库中有这段代码:

已编辑:

// Selector parameter (NSData *)theData

NSMutableURLRequest *aRequest = [[[NSMutableURLRequest alloc] initWithURL:theURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0f] autorelease];

[aRequest setHTTPMethod:@"POST"];
[aRequest setValue:key forHTTPHeaderField:@"Custom-Header"];
[aRequest setValue:@"plain/text" forHTTPHeaderField:@"Content-Type"];

NSMutableData *postData = [NSMutableData data];
[postData appendData:theData];
[aRequest setHTTPBody:postData];

AFHTTPRequestOperation* operation = [[AFHTTPRequestOperation alloc] initWithRequest:aRequest];

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject)
{
_pendingDispatchesCount --;
NSLog(@"%@, %ld", kServerRespondedMsg, (long)operation.response.statusCode);
BOOL statusCodeAcceptable = [[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(200, 100)] containsIndex:[operation.response statusCode]];
dispatch_async(dispatch_get_main_queue(),
^{
[delegate analyticsOperationCompleted:statusCodeAcceptable forData:analyticsData];
});
}
failure:^(AFHTTPRequestOperation *operation, NSError *error)
{
_pendingDispatchesCount --;
NSLog(@"%@, %ld", kServerRespondedMsg, (long)operation.response.statusCode);
dispatch_async(dispatch_get_main_queue(),
^{
[delegate analyticsOperationCompleted:NO forData:analyticsData];
});
}];

[operation start];

如果我只是注释 [operation start]; 示例客户端会正常启动。如果我让操作开始,我会得到 2014-03-24 16:50:56.097 MyApp[1610:4703] -[__NSCFBoolean length]: unrecognized selector sent to instance

此刻让我发疯,因为这个错误只发生在一个开发者身上,他报告了这个错误并且他实际上创建了一个重现它的示例。

编辑:找到了获取堆栈跟踪的方法,这似乎不是由我的应用程序引起的:

回溯:

0   CoreFoundation                      0x000000010201c495 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000101d7b99e objc_exception_throw + 43
2 CoreFoundation 0x00000001020ad65d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010200dd8d ___forwarding___ + 973
4 CoreFoundation 0x000000010200d938 _CF_forwarding_prep_0 + 120
5 CoreFoundation 0x000000010200e9d1 CFURLCreateStringByAddingPercentEscapes + 81
6 CFNetwork 0x0000000103fdf1ab _ZL13appendEscapedP10__CFStringPKS_ + 40
7 CFNetwork 0x0000000103fdef69 _ZL25initializeUserAgentStringv + 124
8 libsystem_pthread.dylib 0x00000001026d58d6 __pthread_once_handler + 65
9 libsystem_platform.dylib 0x00000001025e3156 _os_once + 73
10 libsystem_pthread.dylib 0x00000001026d5875 pthread_once + 57
11 CFNetwork 0x0000000103fdeb23 cleanUpRequest + 105
12 CFNetwork 0x0000000103fde824 _ZN17HTTPNetConnection19prepareTransmissionEP17HTTPNetStreamInfoP17__CoreWriteStream + 1224
13 CFNetwork 0x0000000103fdda65 _ZN13NetConnection7enqueueEPvh + 539
14 CFNetwork 0x0000000103fdd7e4 _ZN17HTTPNetStreamInfo16_streamImpl_OpenEP13CFStreamErrorPh + 88
15 CFNetwork 0x000000010403c295 _ZThn120_N17HTTPNetStreamInfo16_streamImpl_OpenEP13CFStreamErrorPh + 13
16 CFNetwork 0x0000000103fbdfc2 _ZN14CoreStreamBase21_streamInterface_OpenEv + 80
17 CFNetwork 0x0000000103fdd057 _ZN12HTTPProtocol10openStreamEv + 255
18 CFNetwork 0x0000000104048c41 _ZN12HTTPProtocol26useNetConnectionForRequestEP13NetConnectionP15__CFHTTPMessageh + 1753
19 CFNetwork 0x0000000103fdc268 _ZN24HTTPConnectionCacheEntry28dispatchConnectionToProtocolEP13NetConnectionP12HTTPProtocolP18HTTPRequestMessageh + 276
20 CFNetwork 0x0000000103fdc027 _ZN24HTTPConnectionCacheEntry34notifyNextProtocolOfOpenConnectionEP13NetConnectionh + 301
21 CFNetwork 0x0000000103fd9230 _ZN24HTTPConnectionCacheEntry25enqueueRequestForProtocolEP12HTTPProtocolP15__CFHTTPMessage + 650
22 CFNetwork 0x0000000103fd8bf0 _ZN19HTTPConnectionCache34_onqueue_enqueueRequestForProtocolEP12HTTPProtocolP15__CFHTTPMessage + 178
23 CFNetwork 0x000000010404e843 ___ZN19HTTPConnectionCache25enqueueRequestForProtocolEP12HTTPProtocolP15__CFHTTPMessage_block_invoke + 26
24 CoreFoundation 0x0000000101fc2f74 CFArrayApplyFunction + 68
25 CFNetwork 0x0000000103fd43e7 _ZN19RunloopBlockContext7performEv + 133
26 CFNetwork 0x0000000103fd4217 _ZN17MultiplexerSource7performEv + 247
27 CFNetwork 0x0000000103fd403a _ZN17MultiplexerSource8_performEPv + 72
28 CoreFoundation 0x0000000101fabd21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
29 CoreFoundation 0x0000000101fab5f2 __CFRunLoopDoSources0 + 242
30 CoreFoundation 0x0000000101fc746f __CFRunLoopRun + 767
31 CoreFoundation 0x0000000101fc6d83 CFRunLoopRunSpecific + 467
32 Foundation 0x000000010193089c +[NSURLConnection(Loader) _resourceLoadLoop:] + 348
33 Foundation 0x00000001019832df __NSThread__main__ + 1167
34 libsystem_pthread.dylib 0x00000001026d4899 _pthread_body + 138
35 libsystem_pthread.dylib 0x00000001026d472a _pthread_struct_init + 0
36 libsystem_pthread.dylib 0x00000001026d8fc9 thread_start + 13

已编辑:与符号化的完整 PLCrashReporter 崩溃报告链接。 https://drive.google.com/file/d/0B_4YDWJioTI1c0hia25NSXFTWVk/edit?usp=sharing

感谢任何帮助或想法,在此先感谢。

问候。

最佳答案

查看堆栈跟踪并思考可能发生的情况。堆栈跟踪不是什么神奇的东西,它与您的代码直接相关。

崩溃是由某人向包含 Boolean 值的 NSNumber 发送“length”消息引起的。

在堆栈跟踪中,我们看到 CFURLCreateStringByAddingPercentEscapes。所以看起来 CFURLCreateStringByAddingPercentEscapes 是用 NSNumber 对象而不是字符串调用的。

为什么要调用 CFURLCreateStringByAddingPercentEscapes?它通常用于包含 URL 和类似内容的字符串,这些内容不能按原样传输并且需要翻译,例如将空格转换为 %20。

因此,您可能将 NSNumber 传递给将通过网络发送的内容。如 header 属性、URL 等。

检查您在 URL 请求中设置的所有内容。问题可能出在“aRequest”中,特别是因为您决定隐藏它。 (那是潜意识不想让我们看到你的错误,这当然会适得其反)。

关于ios - AFNetworking 和 -[__NSCFBoolean 长度] : unrecognized selector sent to instance 0x1f54358,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22612978/

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