Search code examples
iosswiftrealm

Ambiguous reference to member '==' with realm filter


 do {
        let result = try Realm().objects(Pros.self)
        print(result)
        let filterResult = result.filter({ $0.category.filter({$0.type_cat == ""})})

        print(filterResult)
    }
    catch {

        print(error)

    }

and its give me error as "Ambiguous reference to member '=='" so what i missing to add


Solution

  • I found solution and its work perfectly for me

    do {
                let result = try Realm().objects(Pros.self)
                print(result)
                let predicate = NSPredicate(format: "SELF.type == %@ AND SELF.status == 'valide' AND ANY category.type_sector = %@ AND SELF.status == 'valide'", arrType[(selectedFromType?.row)!], arrTypeSector[(selectedFromSector?.row)!])
                let arrFiltered =  result.filter(predicate)
                print(arrFiltered)
    
    
            }
            catch
            {
                print(error)
    
            }