Realm error: Invalid Value, expecting int and receiving: 0

-EDIT-

  • If you use: id = 'YOUR_VAR_OR VALUE' => means that id is a String (Ex: id ='4')

  • But if you use: id = YOUR_VAR_OR VALUE => means that id is an integer (Ex: id = 4)

NB: So when your id is an integer don't use quotes ' '


Try this:

let idQuery = realm.objects(JournalEntryLine).filter("id = \(item) AND type = 'Debit'")

Transform id = '\(item)' to id = \(item) because id is an Integer, if you use quotes, il will consider id as a string.

Don't forget to vote Up if it helps you. :)


Also it's helped to me:

let matchedMovieID = realm.objects(MovieID.self).filter("movieID == %@", idString).first

Swift 4.2, XCode 10.0, Realm 3.14.1

Tags:

Ios

Swift

Realm