Type Safely

Type Safely

Share this post

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

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

Share this post

Type Safely
Type Safely
Construct An NSPredicate Without Using Strings And Use it To Filter An NSArray
Share
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…

Keep reading with a 7-day free trial

Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Type Safely
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share