I hope that no one tells me to RTFM because I have been struggling with this for some time here and on Apple Developer and doing lots of searching.
I am getting an EXC-BAD-ACCESS error on this statement:
var thisPredicate = NSPredicate(format: "(sectionNumber == %@"), thisSection)
thisSection has an Int value of 1 and displays the value 1 when I hover over it. But in the debug area I see this:
thisPredicate = (_ContiguousArrayStorage ...)
Another predicate using a String shows as ObjectiveC.NSObject Why is this happening?
You will need to change
%@
for%i
and remove the extra parenthesis:Main problem here is that you are putting an
Int
where it's expecting anString
.Here's an example based on this post:
Another workaround would be to make
thisSection
's value anString
, this can be achieved by String Interpolation or viadescription
property of theInt
.. lets say:Changing:
for
or
of course, you can always bypass this step and go for something more hardcoded (but also correct) as:
You might try String Interpolation Swift Standard Library Reference. That would look something like this: