views:

33

answers:

1

My app works great in the simulator under any configuration and in debug configuration on my device but it is crashing on a fetch request I am doing as soon as I create a NSPredicate.

Here is the offending code:

- (void)searchBar:(UISearchBar *)theSearchBar textDidChange:(NSString *)searchText {
    //some fetch request code code

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ItemSKU CONTAINS[c] %@ OR ProductName CONTAINS[c] %@", searchText];

    // more code
}

If I remove this line everything works perfectly, but I have to have this predicate.

+3  A: 

Why do you have two format specifiers with only one getting a value? It's crashing because that's not defined behaviour; if you supply two %@ format specifiers, give searchText and something else, or you will get a crash.

jer
GAH!!! Total oversight and since it worked in debug it never occurred to me that that could be my problem - can't believe I missed that.
Slee
I planned on accepting, just was excited about solving this silly problem
Slee