_NSInlineData objectForKeyedSubscript:

最近总是遇到这个错误:reason: '-[_NSInlineData objectForKeyedSubscript:]: unrecognized selector sent to instance 0x7fa2049bf220'

两个解决方法:

1>用 AFNetworking 进行数据处理的时候,记得加上------  

manager.responseSerializer = [AFJSONResponseSerializer serializer];

就可以了。

2>如果此时打印的 responseObject 还是一串你看不懂字符,想让其转换成可读懂的数据,那么,就在数据解析成功的方法里加上这个-----  

NSString *result = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];

        NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];

        NSLog(@"result1 = %@", result);

        NSLog(@"dic = %@",dic);

综上所述,是因为后台设置的JSon 字符串和AFNetworking 解析出来的不一致,虽说 AFNetworking 本身自带 JSon Text 解析功能,但是保不齐存在不给力的后台队友呢?不影响开发进度的一种方法而已。

原文地址:https://www.cnblogs.com/sandyzhang/p/5844699.html