Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NOT or NONE in NSPredicate



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.