I am making a search function and it works fine on an iphone and the iphone simulator but not the ipad simulator. When I enter my value to search it gives the error basically saying the NSRange is nil:
'NSInvalidArgumentException', reason: '* -[NSCFString rangeOfString:options:range:locale:]: nil argument'
Heres what I have.
for (int i = 0, c = names.count; i < c; ++i) {
sFirst = [firstArray objectAtIndex:i];
sSecond = [secondArray objectAtIndex:i];
NSRange result = [sFirst rangeOfString:searchText options:NSCaseInsensitiveSearch];
NSRange r = [sSecond rangeOfString:searchText options:NSCaseInsensitiveSearch];
if (result.location != NSNotFound) {
[searchedFirst addObject:sFirst];
[searchedSecond addObject:sSecond];
}
if (r.location != NSNotFound) {
[searchedFirst addObject:sFirst];
[searchedSecond addObject:sSecond];
}
}
Can anyone explain to me why this is happening, or is there anything I can do about this problem? Should I not worry about it since its working fine on an actual device?
SOLVED I guess since i was calling the searchText (or searchBar.text) without changing the value into a string first it returned nil. So I just declared a string in the header file.
stringValue = searchBar.text;