一个非常基本但令人费解的错误;
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 但它是从哪里来的?
po'ing *a 和 *s 结果分别为;
*一个:
(NSMutableArray *) $3 = 0x088941f0 {
Genre = Rock;
Name = Creed;
"New item" = Higher;
}
*s:
(int) $4 = 143213040 {
Genre = Rock;
Name = Creed;
"New item" = Higher;
}
我想不通,我一直在寻找,但该错误本质上非常笼统/模糊,无法获得具体答案。(我的两分钱)
TIA