无法识别的选择器(NSMutableArray + NSString)

时间:2012-12-19 07:09:43

标签: ios nsstring nsmutablearray unrecognized-selector

一个非常基本但令人费解的错误;

NSString *selectedCategory = @"Rock";

if (self.quoteOpt.selectedSegmentIndex == 1) 
{
        selectedCategory = @"Programming";
}

//filter array by ti tle using predicate
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"Genre == %@", selectedCategory];
NSArray *filteredArray = [self.movieQuotes filteredArrayUsingPredicate:predicate];

int array_tot = [filteredArray count];

if(array_tot > 0)
{
   int index = (arc4random() % array_tot);
   NSMutableArray *a = [filteredArray objectAtIndex:index];
   NSString *s = [a objectAtIndex:1];
   self.quoteText.text = [NSString stringWithFormat:@"Genre \n\n %@",s];
}
else
{
   self.quoteText.text = [NSString stringWithFormat:@"No quotes to display."];
}

我对它的行为方式感到困惑,所产生的错误来自

NSString *s = [a objectAtIndex:1];

我做了一个po hexaddress,它似乎是int但是它来自哪里?

分别为* a和* s结果;

*一个:

(NSMutableArray *) $3 = 0x088941f0 {
  Genre = Rock;
  Name = Creed;
  "New item" = Higher;
 }

* S:

(int) $4 = 143213040 {
  Genre = Rock;
  Name = Creed;
  "New item" = Higher;
}

我无法弄明白,我一直在寻找,但错误是非常通用/模糊的,没有具体的答案可以获得。 (我的两分钱)

TIA

0 个答案:

没有答案