objective-c - 无法将 JSON 放入 NSDictionary

标签 objective-c json nsdictionary

我正在尝试将我的 JSON 放入 NSDictionary 中。我正在做以下事情:

 NSData *innerData = [json objectForKey:@"data"];
                NSLog(@"Inner Description %@", innerData);

                NSError* error;
                NSDictionary* json = [NSJSONSerialization
                                      JSONObjectWithData:innerData 
                                      options:kNilOptions
                                      error:&error];
                NSLog(@"dict: %@",json);

它在创建字典时一直崩溃并出现此错误。

-[__NSCFDictionary bytes]: unrecognized selector sent to instance 0x1e8d6100

有人能帮忙吗?

最佳答案

innerData 在运行时是一个 NSDictionary,而不是你期望的 NSData。

关于objective-c - 无法将 JSON 放入 NSDictionary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14071341/

相关文章:

swift - 如何在 swift 4 中对数组中的 JSON 数据进行排序

iphone - 在 Objective C 中创建 JSON 格式

ios - 如何在不改变顺序的情况下从plist加载数据

ios - UICollectionViewCell 大小错误

objective-c - 苹果操作系统 X : Get current username and home directory for current user from Directory Services

iphone - 比 -forwardInspiration : to perform messages on a specific thread 更快的方法

php - MySQL 与文件数据库

javascript - 如何在 Javascript (jQuery) 中使用递归函数创建动态 html 列表

iphone - 在选项卡式 View 应用程序中滑动手势

javascript - 从/到 Javascript 字符串从 Go int64/uint64 序列化反序列化