2 lianlianbushell lianlianbushell 于 2012.11.28 09:46 提问

NSPredicate的AND和OR问题

NSPredicate语句:

fetchRequest.predicate = [NSPredicate predicateWithFormat:@"url = %@ AND type = %@ OR type = %@", newsStory.url, [NSNumber numberWithInt:StoryHighlighted], [NSNumber numberWithInt:StorySavedAndHighlighted]];

实现的是通过指定URL获取story并且标记(高亮),但是查询结果不正常。不知道该怎么实现?

1个回答

g989_1314125
g989_1314125   2012.11.28 10:14
已采纳
fetchRequest.predicate = [NSPredicate predicateWithFormat:@"url = %@ AND (type = %@ OR type = %@)", newsStory.url, [NSNumber numberWithInt:StoryHighlighted], [NSNumber numberWithInt:StorySavedAndHighlighted]];

应该可以用。用用试试吧

lianlianbushell
lianlianbushell 不好意思,这么久才采纳,谢谢O(∩_∩)O
接近 5 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片