Type Safely

Type Safely

Construct An NSPredicate Without Using Strings And Use it To Filter An NSArray

Daily Coding Tip 082

Millie Sturgeon's avatar
Millie Sturgeon
May 07, 2022
∙ Paid
Image by Karl Egger from Pixabay

This is a simple way to use NSPredicate without needing to construct a format string.

It’s possible to construct NSPredicate using a closure, which means I can also pass it data from computed properties.

I have a person structure here which conforms to Identifiable, allowing me to display it in a ForEach later. This just m…

User's avatar

Continue reading this post for free, courtesy of Type Safely.

Or purchase a paid subscription.
© 2026 Type Safely · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture