On 29 May 2008, at 02:02, [EMAIL PROTECTED] wrote:
5/28/08 12:10 PM, also sprach [EMAIL PROTECTED]:
NSString *searchString = @"SpoD";
NSString *predicateFormat = @"kMDItemFSName contains %@";
NSPredicate *predicate = [ NSPredicate predicateWithFormat:
predicateFormat, searchString ];
NSMetadataQuery *query = [[NSMetadataQuery alloc] init];
[ query setPredicate: predicate]; // <---- creates exception
NSComparisonPredicate with left expression which is not
NSKeyPathExpressionType given to NSMetadataQuery ("SpoD" IN
kMDItemFSName)
When I use beginswith, endswith or == instead of "contains" it works
fine.
So how can I find all filenames wich contain a given string? (Btw.
"matches" also does not work).
kMDItemFSName is not an attribute name--it is a constant that
represents an
attribute name.
OTOH, try:
NSString *predicateFormat = @"%K contains %@";
NSPredicate *predicate = [NSPredicate
predicateWithFormat:predicateFormat,
searchString, kMDItemFSName];
Following your suggestion I found two solutions:
NSString *predicateFormat = @"%@ contains %K";
NSPredicate *predicate = [NSPredicate predicateWithFormat:
predicateFormat, searchString, kMDItemFSName];
or:
NSString *predicateFormat = @"%@ contains kMDItemFSName";
NSPredicate *predicate = [ NSPredicate predicateWithFormat:
predicateFormat, searchString ];
The predicate seems sort of backwards - but at least it works.
Thanks a lot for your suggestion!
Kind regards,
Gerriet.
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
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/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]