开发者

Why does nspredicate crash?

I wanted to check if a field contains data or not. Here's my code:

[fetchRequest setPredicate:[NSPredicate predicateWithFormat:
                            @"( SeriesStudyID == 开发者_运维问答 %@ )" ,"" ]];

But it crashes. Why?


@iAnand's answer is wrong. Using %@ in a predicate format string is perfectly acceptable.

The problem is that %@ means to substitute in an object, but you're substituting in "", which is not an object, but a char*. Thus, you need to simply add an @ sign in front of the double quotes to turn it from a char* into an NSString.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜