Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 12-24-2009, 10:19 PM   #1 (permalink)
MobileJoel
Registered Member
 
Join Date: Nov 2009
Posts: 4
MobileJoel is on a distinguished road
Default Odd behavior with NSPredicate and NSMutableArray

Merry Christmas Eve,

In the code below I've got two lines that create the NSPredicate 'searchPredicate' (they're both uncommented here, but in practice I alternate commenting one or the other out to test). When I use the testArray to create the predicate all is great and I get the results I expect, but when I use the self.currentDeckSwitchedOnCategoryArray I get zero results. I have checked many times to ensure both arrays have the same content (see console output below - differing the order of elements does not seem consequential). The only difference between the arrays is that one is an NSArray and the other is an NSMutableArray, although I have tried to convert the latter into an NSArray to see if that was the issue - no joy. Other ideas were the spaces in the strings or even that quotes appear around output in the console (typical when strings contain non-alphanumeric characters). Can anyone spot something that would cause this different behavior or suggest a fix to the problem?
Thanks and hope I can get this straightened out before Xmas day, Joel

>>>>>>>>>

NSArray* testArray = [[NSArray alloc] initWithObjects:@"Upper Body", @"Middle Body", @"Lower Body", @"Full Body", @"Wildcard", nil];
NSLog(@"self.currentDeckSwitchedOnCategoryArray values: %@", self.currentDeckSwitchedOnCategoryArray);
NSLog(@"testArray values: %@", testArray);
NSPredicate *searchPredicate = [NSPredicate predicateWithFormat:@"(ANY Decks.Name == %@) && (Category IN %@)", [deckObject valueForKey:@"Name"], testArray];
NSPredicate *searchPredicate = [NSPredicate predicateWithFormat:@"(ANY Decks.Name == %@) && (Category IN %@)", [deckObject valueForKey:@"Name"], self.currentDeckSwitchedOnCategoryArray];
[fetchRequest setPredicate:searchPredicate];
NSFetchedResultsController* tempFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:@"Root"];
tempFetchedResultsController.delegate = self;
self.fetchedResultsController = tempFetchedResultsController;

>>>>>

2009-12-24 20:44:47.500 FDM_v2.0.25x[819:20b] testArray values: (
"Upper Body",
"Middle Body",
"Lower Body",
"Full Body",
Wildcard
)
2009-12-24 20:44:47.525 FDM_v2.0.25x[819:20b] self.currentDeckSwitchedOnCategoryArray: (
"Full Body",
"Upper Body",
"Middle Body",
"Lower Body",
Wildcard
)
MobileJoel is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,421
Threads: 94,016
Posts: 402,539
Top Poster: BrianSlick (7,978)
Welcome to our newest member, maryleeag34
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:46 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.