Skip to main content

I had the issue where I needed to filter an array list by a specific column.  In my instance, the column is language.  To be able to reduce the query to the language column the code required is

levels = selectedCategory?.levels.filter("language = %@", language)

Language can be any string, in this instance for me language is a two alpha character such as 'fr', 'en' or 'de'.

Further to this you can continue to chain this query through including sort as per

levels = selectedCategory?.levels.filter("language = %@", language).sorted(byKeyPath: "title", ascending: true)

 

Related articles