NSInvalidArgumentException',原因:' - [__ NSArrayI length:无法识别的选择器发送到实例

use*_*579 3 cocoa-touch objective-c uitableview ios unrecognized-selector

当我从谷歌寻找答案时,大多数答案都说你试图在NSArray上使用不受支持的长度.

这里的问题是我甚至没有在我的代码中使用任何NSArray或长度.

我有一个

NSMutableArray *filteredContent;   
Run Code Online (Sandbox Code Playgroud)

哪里filteredContent将包含来自plist的字典.

一切都很好,直到写cell.textLabel.text在牢房上tableView.
选中NSLog并且内容确实是一个数组.

这是我尝试编写单元格文本的方法:

cell.textLabel.text=[[self.filteredContent objectAtIndex:indexPath.row] valueForKey:@"recipeName"];
Run Code Online (Sandbox Code Playgroud)

但它给了我错误所以我改为:

NSString *myValue = [self.filteredContent valueForKey:@"recipeName"];
cell.textLabel.text=myValue;
Run Code Online (Sandbox Code Playgroud)

但结果是一样的.我不知道我得到了什么错误.

更多详情:

[results addObject:@[recipe]];
Run Code Online (Sandbox Code Playgroud)

这是我创建主数组的地方,而不是将其传递给PageViewwith seguefilteredContent = results


编辑:

recipe = arrayOfPlist[i]; 其中arrayOfPlist

NSArray *arrayOfPlist = [[NSArray alloc] initWithContentsOfFile:path];
//Output to NSLog(@"FIltered Content :  %@", self.filteredContent);
FIltered Content :  (
        (
            {
                category = main;
                difficultyLevel = "3/5";
                numberOfPerson = 5;
                recipeDetail = "Bulguru koy su koy beklet pisir ye ";
                recipeImage = "nohutlu-pilav.jpg";
                recipeIngredients = "pirinc,tereyag tuz,bulgur";
                recipeName = "Bulgurlu Pilav";
                time = "25 dk";
            }
        ),
        (
            {
                category = main;
                difficultyLevel = "3/5";
                numberOfPerson = 5;
                recipeDetail = "Bulguru koy su koy beklet pisir ye ";
                recipeImage = "nohutlu-pilav.jpg";
                recipeIngredients = "pirinc,tereyag tuz,bulgur";
                recipeName = "Bulgurlu Pilav";
                time = "25 dk";
            }
        )
    )

    2014-04-27 02:47:41.704 deneme2[19820:60b] VALUE IN FILTERED TABLE  is (
        "Bulgurlu Pilav" // this is what i want to write to the cell label and i get it with myValue-look a bit above
    )
Run Code Online (Sandbox Code Playgroud)

rma*_*ddy 5

根据您的数据输出,您有一个额外的数组.所以你想要这个:

cell.textLabel.text = self.filteredContent[indexPath.row][0][@"recipeName"];
Run Code Online (Sandbox Code Playgroud)

filteredContentArray的每个元素都是另一个数组.每个内部数组都有包含所需数据的字典.

  • 你这样做 - `[结果addObject:@ [recipe]];`你正在添加一个元素,它是一个元素,这是你的食谱arrayOfPlist.你可能只是想要`[结果addObject:recipe]`? (2认同)