Realm on iPhone Exception on read

I will not speak for the MongoDB Realm folks but it’s not likely a bug in Realm. It’s likely a bug in your code - implementation or perhaps even overlooking something obvious. It happens!

Diagnosing an issue is very challenging here as without a solid troubleshooting path and code visibility, it’s hard to isolate the issue. There are some things you can do to help narrow it down.

I always have a button in my UI that allows me to isolate and test code. So in this situation I would add this code to my button action

@IBAction func myButtonAction( _ sender: Any ) {
   let realm = try! Realm()
   let results = realm.objects(PersonalData.self )
   print(results.count) //output to a text field
}

Obviously when you are running it on the device you don’t have a console so perhaps at a temporary text field in your UI where you can send output that would normally go to the console in the simulator.

Does that code output 1 or 0? If it’s 0 that tells us the Realm has no data. If 1 then it has data so then look further into how the data is being read. For example, this is not correct

var users: Results?

but this is

var personResults: Results<PersonalData>? = nil

Then inside functions to access the class var personResults, use self (for clarity) as in

func loadPeople() {
   let realm = try! Realm()
   self.personResults = realm....
}