开发者

Why does nspredicate crash?

开发者 https://www.devze.com 2023-03-08 17:10 出处:网络
I wanted to check if a field contains data or not.Here\'s my code: [fetchRequest setPredicate:[NSPredicate predicateWithFormat:

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

精彩评论

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

关注公众号