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
.
精彩评论