iPad search bar bad memory access?

Posted by Geoff Baum on Stack Overflow See other posts from Stack Overflow or by Geoff Baum
Published on 2010-09-16T14:53:54Z Indexed on 2011/01/13 9:53 UTC
Read the original article Hit count: 150

Filed under:
|
|
|
|

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!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c