-(void)downloadResult:(id)data
{
   if([data isKindOfClass:[NSArray class]])
   {
       if ([data count]==3)
       {
           if ([dataResultDictionary count])
           {
                [[dataResultDictionary objectForKey:[data objectAtIndex:0]] addObject:[NSMutableArray arrayWithObjects:[data objectAtIndex:1],[data lastObject], nil]];
           }
           else
           {
               [dataResultDictionary setObject:[NSMutableArray arrayWithObject:[NSMutableArray arrayWithObjects:[data objectAtIndex:1],[data lastObject], nil]] forKey:[data objectAtIndex:0]];
           }
           if([dataResultDictionary count])
           {
                if ([[dataResultDictionary objectForKey:[data objectAtIndex:0]] count] == requiredResultCount)
                 {
                    [downloadControlQueue cancelAllOperations];
                    [downloadControlQueue release];
                    downloadControlQueue = nil;
                    processing = YES;
                    [self procesResultData];
                }
            }

      }
      else
      {
            BOOL errorResult = TRUE;

            if ([data count])
            {
                        if ([[data lastObject] isKindOfClass:[NSMutableDictionary class]]) {
                            if ([[data lastObject] count]) {
                                if ([[[[data lastObject] allValues] objectAtIndex:0] count]) {

                                    [dataResultDictionary setObject:[data lastObject] forKey:[data objectAtIndex:0]];
                                    errorResult = false;
                }

               }
          }
       }

            if(errorResult)
            {
                [dataResultDictionary setObject:@"" forKey:[data objectAtIndex:0]];
            }
            if ([dataResultDictionary count] == requiredResultCount) {
                [downloadControlQueue cancelAllOperations];
                [downloadControlQueue release];
                downloadControlQueue = nil;
                processing = YES;
                [self procesResultData];

            }
            }
        }


    }


我正在从服务器获取数据。我想以图像中的%值显示下载结果。但是我要崩溃了。最初,此方法正在工作。我在图像中显示的数据高达70%,但其余部分却被破坏了
。帮我

最佳答案

根据rakeshNS的建议,对您的查询的答案似乎不是[dataResultDictionary objectForKey:[data objectAtIndex:0]]。相反,它是一个NSMutableArray

为什么要尝试在解析的数组中NSString,它是不可更改的(bcc)(addObject:)?您应该真正重新考虑解析逻辑。如果需要,请创建一个单独的模型类来存储解析的数据。您可以创建可变数组并将值存储在此模型类中。

关于ios - 'NSInvalidArgumentException',原因:'-[__ NSCFConstantString addObject:]:无法识别的选择器已发送到实例,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18652436/

10-11 14:43