NOT or NONE in NSPredicate
NOT or NONE in NSPredicate
- Subject: NOT or NONE in NSPredicate
- From: Chad Harrison <email@hidden>
- Date: Thu, 17 Jul 2008 22:52:46 -0400
I have a fairly complex NSPredicate which works correctly, but I am
trying to compound it with with a subpredicate that contains a logical
NOT. I have tried using many combinations of the predicate syntax, but
I can't seem to get it working. What I am trying to do it exclude
files from being picked up based on an NSArray of names
these don't work
NSPredicate *doesNotContainTheseFilesPredicate = [NSPredicate
predicateWithFormat:@"NONE (kMDItemFSName in %@)", myFileNameArray];
NSPredicate *doesNotContainTheseFilesPredicate = [NSPredicate
predicateWithFormat:@"NONE kMDItemFSName in %@", myFileNameArray];
I also tried creating separate NSPredicates and then ANDing them
together like
NSPredicate *doesNotContainThisFile1Predicate = [NSPredicate
predicateWithFormat:@"NOT (kMDItemFSName LIKE %@)", @"filename.txt"];
NSPredicate *doesNotContainThisFile2Predicate = [NSPredicate
predicateWithFormat:@"NOT (kMDItemFSName LIKE %@)", @"filename2.txt"];
predicateToRun = [NSCompoundPredicate andPredicateWithSubpredicates:
[NSArray arrayWithObjects:predicateToRun,
doesNotContainThisFile1Predicate,
doesNotContainThisFile2Predicate,
nil]];
In some cases I just get an empty results, and in others I get "Unable
to parse the format string"
Is there a better way to exclude files based on name alone?
thanks
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden