Ios [\uuu NSSingleEntryDictionaryI元素]:发送到实例0x2836c2820的无法识别的选择器

Ios [\uuu NSSingleEntryDictionaryI元素]:发送到实例0x2836c2820的无法识别的选择器,ios,objective-c,xcode,nsarray,nsdictionary,Ios,Objective C,Xcode,Nsarray,Nsdictionary,嗯,我应该记得你,我还是一个iOS开发的初学者,使用objective c。也许正因为如此,解决方案很简单,但我看不出来。我有一个json,他的武装方式如下: { "origin_addresses": [ "Test" ], "rows": [ { "elements": [ { "distance": { "text": "0.3 km",

嗯,我应该记得你,我还是一个iOS开发的初学者,使用objective c。也许正因为如此,解决方案很简单,但我看不出来。我有一个json,他的武装方式如下:

{
   "origin_addresses": [
      "Test"
   ],
   "rows": [
      {
         "elements": [
            {
               "distance": {
                  "text": "0.3 km",
                  "value": 339
               },
               "duration": {
                  "text": "1 min",
                  "value": 82
               },
               "status": "OK"
            }
         ]
      }
   ],
   "status": "OK"
}
应用程序可以毫无问题地使用该服务。我的目标是达到距离属性。我是这样做的。我使用一个foreach遍历数组,然后使用另一个foreach遍历数组元素

for (BPCGARows *item in googleAddress.rows) {
            NSLog(@"rows : %@", item);
            for (BPCGAElements *element in item.elements) {

            }
        }
当我调试应用程序时,我的第一个for each可以正常工作,但是当我访问第二个foreach时,(item.elements中的BPCGAElements*元素)应用程序崩溃。最后,我也无法在日志中打印item.elements。错误消息如下所示:

“NSInvalidArgumentException”,原因:“-[\uu NSSingleEntryDictionaryI” 元素]:发送到实例0x281c75da0'的无法识别的选择器

标题BPCGADistance:

@interface BPCGADistance : MBOInspectableModel

@property (nonatomic, strong, readonly) NSString *text;
@property (nonatomic, strong, readonly) NSNumber *value;

@end
主要BPC立场:

@interface BPCGADistance()

@property (nonatomic, strong, setter=text:) NSString *text;
@property (nonatomic, strong, setter=value:) NSNumber *value;

@end

标题BPCGA元素:

@interface BPCGADistance : MBOInspectableModel

@property (nonatomic, strong, readonly) NSString *text;
@property (nonatomic, strong, readonly) NSNumber *value;

@end
主要BPCGA元素:

@interface BPCGADistance()

@property (nonatomic, strong, setter=text:) NSString *text;
@property (nonatomic, strong, setter=value:) NSNumber *value;

@end

这是我的NSLog(@“行:%@”,项), 我强调,通过使用item.elements在控制台上打印crashea应用程序


BPCGARows*项
是一个
NSDictionary
,而不是
BPCGARows
。您是如何将JSON转换为自定义对象的(
BPCGARows
BPCGAEElements
)?我刚刚通过添加BPCGARows和BPCGAEElements模型更新了我的答案@LarmeBut正如我提到的,我的模型生成得很好,因为我可以在控制台上打印服务的响应@LARME
NSLog(@“行:%@”,项)的输出是什么?你给了我什么?因为这是JSON,而不是BPCGARows。您在哪里将JSON响应初始化到自定义对象中的?@Larme我刚刚通过在控制台中添加打印更新了我的问题