所以我试图在我的应用程序中实现一个搜索栏,并且非常接近,但似乎无法弄清楚发生这种内存错误的位置。这就是我的搜索方法的一部分,看起来像:iPad搜索栏内存访问不良?
filters = [[NSMutableArray alloc] init];
NSString *searchText = detailSearch.text;
NSMutableArray *searchArray = [[NSMutableArray alloc] init];
// Normally holds the object (ex: 70 locations)
searchArray = self.copyOfFilters ;
//This is the line that is breaking after ~2-3 letters are entered in the search
for (NSString *sTemp in searchArray)
{
NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch];
if (titleResultsRange.length > 0)
[filters addObject:sTemp];
}
displayedFilters = filters;
copyOfFilters是当通过视图首次加载显示的显示过滤器的深层副本:
self.copyOfFilters = [[NSMutableArray alloc] initWithArray:displayedFilters copyItems:YES];
我走过的进入追踪字母和它在2个字母后是准确的,但是一旦您尝试在搜索栏中的空格后输入一个字母,它就会崩溃。 copyOfFilters = {(int)[$ VAR count]}对象的值。有谁知道可能是什么原因造成的?谢谢!
你有没有在GDB尝试“po searchArray”?它输出的是什么 – VdesmedT 2010-09-16 15:13:40
我解决了它,看到我对你的答案的评论。 :) – gabaum10 2010-09-16 15:20:10