ios - 'NSInvalidArgumentException',原因 : '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance

标签 ios objective-c json

下面是我的代码

   nameLabel.text=[[[dict_Details objectForKey:@"unknown_object"] objectAtIndex:0] objectForKey:@"UserFullName"];

这是我的回复

获取用户评论响应

{
"status_code" = 200;
"unknown_object" = "[{ID:227,ServiceProviderName:Dr.KarthikMendi,UserFullName:karthik,ReviewTemplateID:19,TotalScore:88.0,ServiceName:Doctor,Review:Very knowlegable doctor he understands the problem very well.,ServiceID:5,CommentsBySP:Thank you...,ServiceProviderID:0,CommentByAdmin:null,UserID:106,Status:true,CreatedDate:2016-05-06T18:30:08,Services:null,ServiceProviderTypes:null},{ID:168,ServiceProviderName:Dr.KarthikMendi,UserFullName:karthik,ReviewTemplateID:19,TotalScore:92.0,ServiceName:Doctor,Review:I am very impressed.  Very organized and professional.\\r\\nI always leave feeling taken care of and medical needs met. \\r\\nNeed more Dr\U00e2\U0080\U0099s like him!\\r\\nGreat!  He gave me sufficient time!\\r\\nVery friendly, informed and hospitable. \\r\\nVery nice \U00e2\U0080\U0093 didn\U00e2\U0080\U0099t feel like a number, but an actual person.,ServiceID:5,CommentsBySP:Thank you,ServiceProviderID:0,CommentByAdmin:null,UserID:84,Status:true,CreatedDate:2016-03-23T10:12:19.087,Services:null,ServiceProviderTypes:null}]";
}

最佳答案

“unknown_object”的值是一个字符串,但您在调用 objectForKey: 时假设它是一个字典。因此异常(exception)。

总的来说,我会说 JSON 是“坏的”,因为它需要双重反序列化,这没什么用。

关于ios - 'NSInvalidArgumentException',原因 : '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37434258/

相关文章:

ios - SKPhysicsBody 不适用于 SKShapeNode

iphone - 如何更有效地编写一些条件代码?

objective-c - NSManagedObject 的副本

ios - 使用 jsonkit iOS 解析 json 提要

ios - Xcode-Maven-Plugin 是否可以在 PC 上构建 iOS 应用程序

ios - React Native WebView (iOS) 中的 SVG 加载问题

iPhone - 如何阻止 UIWebView 绘制/更新其内容

Xcode 存档构建、临时构建和新设备

java - jackson 序列化奇怪的输出

sql - 如何查询 MySQL JSON 列数据的空值?