gpt4 book ai didi

ios - iOS10 中不尊重 NSMutableDictionary 的 Objective-C 类别

转载 作者:搜寻专家 更新时间:2023-10-30 20:14:11 29 4
gpt4 key购买 nike

我有一个用 Objective-C 编写的应用程序,其中包含一个 NSMutableDictionary 类别。在 iOS9 中,该应用程序运行良好。但是,当在 iOS10 中运行时,应用程序会因“无法识别的选择器发送到实例”而崩溃。我已将问题隔离到 NSMutableDictionary 类别在 iOS10 中不受尊重。

NSMutableDictionary 的类别包括以下方法:

- (id)getObjectForStringKeyPath:(NSString *)keysPath {
NSArray *dividedString = [keysPath componentsSeparatedByString:@"/"];
return [self getObjectForKeyPath:dividedString];
}

它崩溃的行是(响应类型为“id”):

NSArray *textArray = [response getObjectForStringKeyPath:"someText/text"];

我已经检查了来自服务器的响应,响应是有效的。另外正如我所提到的,崩溃不会发生在 iOS9 上。它只发生在 iOS10 上。

有谁知道如何解决这个问题,或者有什么方法可以解决这个问题?

崩溃日志

-[__NSSingleEntryDictionaryI getObjectForStringKeyPath:]: unrecognized selector sent to instance 0x608000a3f3e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSSingleEntryDictionaryI getObjectForStringKeyPath:]: unrecognized selector sent to instance 0x608000a3f3e0'
*** First throw call stack:
(
0 CoreFoundation 0x000000011036034b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010fdc121e objc_exception_throw + 48
2 CoreFoundation 0x00000001103cff34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00000001102e5c15 ___forwarding___ + 1013
4 CoreFoundation 0x00000001102e5798 _CF_forwarding_prep_0 + 120
5 XYZApp 0x000000010c919b7e __64-[XYZController configureConditionsTextFromHTML:]_block_invoke + 126
6 XYZApp 0x000000010c8e973f __41-[XYZDataProvider getTermsAndConditions:]_block_invoke + 159
7 XYZApp 0x000000010c8fd5ae -[XYZManager handleSuccessfulResponse:andResponseBlock:] + 110
8 XYZApp 0x000000010c8fbede __50-[XYZManager GET:withParameters:andResponseBlock:]_block_invoke + 126
9 libdispatch.dylib 0x0000000110872980 _dispatch_call_block_and_release + 12
10 libdispatch.dylib 0x000000011089c0cd _dispatch_client_callout + 8
11 libdispatch.dylib 0x000000011087ca1d _dispatch_main_queue_callback_4CF + 733
12 CoreFoundation 0x00000001103244f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 CoreFoundation 0x00000001102e9f8d __CFRunLoopRun + 2205
14 CoreFoundation 0x00000001102e9494 CFRunLoopRunSpecific + 420
15 GraphicsServices 0x00000001131c9a6f GSEventRunModal + 161
16 UIKit 0x000000010e573f34 UIApplicationMain + 159
17 XYZApp 0x000000010c92698f main + 111
18 libdyld.dylib 0x00000001108e868d start + 1
19 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

最佳答案

错误表明对象类型是 __NSSingleEntryDictionaryI,而不是您期望的 NSMutableDictionary

制作服务器提供给您的字典的可变副本,并将那个分配给response

关于ios - iOS10 中不尊重 NSMutableDictionary 的 Objective-C 类别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39495680/

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