For the use within Core Data I tried to build a NSPredicate
object. minLength
and maxLength
are of typeint
:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"length >= %@ AND length <= %@",
minLength, maxLength];
The program crashes here with an EXC_BAD_ACCESS
. This is not the case if I use %d
instead of %@
:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"length >= %d AND length <= %d",
minLength, maxLength];
What am I missing here?
%@
is the format specifier for objects. An int
is not an object. The format specifier for signed integers is %d
or %i
.
In format for int, you shouldn't use %@
, but %i
. %@
is for objects`.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With