I need to append my custom string into NSPredicate.
So I wrote following codes.
self.query = [[NSMetadataQuery alloc] init];
[self.query setSearchScopes: [NSArray arrayWithObject:NSMetadataQueryUbiquitousDocumentsScope]];
NSPredicate *pred = [NSPredicate predicateWithFormat:@"%K like '%@*'",NSMetadataItemFSNameKey,whereAreYou];
NSLog(@"%@",pred.description);
[self.query setPredicate:pred];
However when I test it , it only return following value.
kMDItemFSName LIKE "%@*"
the placeholder %@ is not append correctly. It only showing %@ sign.
How can I do that?
Format arguments inside quotation marks are not expanded by
predicateWithFormat, therefore@"%K like '%@*'"does not work.This should work: