vbwx
vbwx

Reputation: 388

Code working on Simulator, but not on iPhone?

I am stumped by this: I've tested the filter function of my app in the iPhone Simulator 4.3 and 5.0 and everything works, but on the iPhone the predicate gets me the wrong results. (I suspect it has something to do with the regex, but I don't see an error.)

if (!selectionDidChange)
    return;
[matches release];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"meta LIKE[c] %@",
                          UniversalKeyword];
NSPredicate *regional = [NSPredicate predicateWithFormat:@"regional == NIL OR regional == NO OR "
                         @"(regional == YES AND title.%K != NIL)", CurrentLanguage];
NSPredicate *exclusive = (exclusiveUpgrade ? [NSPredicate predicateWithValue:YES] :
                          [NSPredicate predicateWithFormat:@"exclusive == NIL OR exclusive == NO"]);
NSMutableArray *predicates = [[[NSMutableArray alloc] initWithCapacity:5] autorelease];
for (int i = 0; i < L(keywords); i++)
{
    int selection = [D(A(keywords, i), @"selection") intValue];
    if (selection >= 0)
        A_ADD(predicates, ([NSPredicate predicateWithFormat:@"meta MATCHES[c] %@",
                            S(S(@".*\\b", D(A(D(A(keywords, i), @"values"), selection), @"name")), @"\\b.*")]));
}
NSPredicate *compound = [NSCompoundPredicate andPredicateWithSubpredicates:predicates];
[predicates removeAllObjects];
[predicates addObject:predicate];
[predicates addObject:compound];
predicate = [NSCompoundPredicate andPredicateWithSubpredicates:A_NEW(regional, exclusive,
            [NSCompoundPredicate orPredicateWithSubpredicates:predicates])];
matches = [[entries filteredArrayUsingPredicate:predicate] retain];
selectionDidChange = NO;

For clarification:

What am I overlooking here?

Upvotes: 0

Views: 970

Answers (1)

vbwx
vbwx

Reputation: 388

Here are the key points in case anybody else has a similar problem:

  1. There are no functional differences between NSPredicate on the iPhone and the corresponding implementation on the iOS Simulator.
  2. If your app behaves differently on the actual device than on the Simulator, double-check file names and other strings for capitalization, like jmstone said.
  3. If the problem persists, remove the app both from the Simulator and from the device. Xcode has many automatic behaviors, but it doesn't clean up anything on the Simulator or the device.

Upvotes: 1

Related Questions