3

Below is the code for getting Filtered list from Realm List but when i am passing predicate to list it is giving me crashing.

var services : List<ServiceBO>?
let predicate : NSPredicate = NSPredicate(format: "isFavorite == yes", "")
            let li = .services?.filter(predicate)
Shehbaz Khan
  • 1,892
  • 3
  • 24
  • 31

1 Answers1

-3

You can try this.This code filters all the available objects of kind ServiceBO with evaluating your condition i.e isFavorite == yes

let filteredServices = realm.objects(ServiceBO).filter("isFavorite == yes")

Hope this helps you..!!

Vishal Sonawane
  • 2,637
  • 2
  • 16
  • 21
  • Actually i wants to query on List not from Realm Object – Shehbaz Khan Apr 19 '17 at 07:14
  • As Vishal noted, only Lists retrieved from Realms can be queried. However, you can convert unmanaged Lists to an Array and filter using Array's methods: `Array(services).filter { $0.isFavorite }` – jpsim Apr 20 '17 at 00:16