用AFN3.0请求返回的数据是NSCFDictionary *类型 执行setValue: forKey: 崩溃

it2024-12-15  34

在AFN返回的数据字典中,运用setValue: forKey:一直崩溃,打印了一下返回的数据是 NSCFDictionary *  类型的,在网上查找了好久的资料,终于找到解决的办法

原来是 AFN响应序列器的设置问题,我们需要把它设置成可变类型

我们项目原来设置的是

self.responseSerializer = [AFJSONResponseSerializer serializer];

所以不能使用 setValue forkey

应该改成:

self.responseSerializer = [AFJSONResponseSerializer serializerWithReadingOptions: NSJSONReadingMutableContainers];

问题解决!

转载于:https://www.cnblogs.com/yulongjiayuan/p/5973871.html

最新回复(0)