Creating NSPredicate dynamically by setting the key programmatically
Why does the former of following snippets work while not the latter ? Snippet 1 NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(coin_unique == %@)", [NSNumber numberWithInt:species]]; Snippet 2 // Does NOT Work NSString *predicateText = @"coin_unique"; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(%@ == %@)", predicateText, [NSNumber numberWithInt:species]]; I have to dynamically create predicate depending upon the argument received in my method. coin_unique is a key, so it needs the %K format specifier: NSString *predicateText = @"coin_unique"; NSPredicate