iPad search bar bad memory access?
- by Geoff Baum
Hello all,
So I am trying to implement a search bar in my app and am very close but can't seem to figure out where this memory error is occurring. This is what part of my search method looks like:
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 is a deep copy of the displayed filters that appear when the view first loads via:
self.copyOfFilters = [[NSMutableArray alloc] initWithArray:displayedFilters copyItems:YES];
I have traced through the entry of letters and it is accurate after 2 letters, but once you try and enter a letter after a space in the search bar, it crashes. The value of copyOfFilters = {(int)[$VAR count]} objects. Does anyone know what may be causing this? Thanks!