I am using Realm for a small, simple project. I'm using the latest version of the framework (compiled from Github yesterday) and the current AppStore version of Xcode with Swift 2.1.
I am handing a Realm database object over from one view controller to another via a segue in prepareForSegue()
, in order to edit it (and fill out the current values).
Somehow, there seems to be a problem with the object in the target view controller. When I simply print()
the object in the target view controller (either in viewDidLoad()
or any of the methods I plan to use it in), the object is properly shown in the console like so:
Object {
name = asdf
value = 8
}
and so on.
If I try to access the values (even in the previous or next line) and assign them to another variable like myValue = objectToEdit.value
I get 0.
Debugging the code by stepping into it with breakpoints shows the object in the debugger with all values empty ("") or 0, depending on the type. Still, somehow Strings are grabbed out of it for some reason, I can access and print them with myString = objectToEdit.name
, while the debugger shows name = (String) ""
, claiming it's empty.
The same behavior already occurs when I get the database object out of the database in the first view. The immediate thought would be, that the values are indeed 0 and only the strings were saved, but the print()
method says otherwise.
Can anybody explain this odd behavior and maybe show me where I overlooked something? I now suspect it's some internal problem of the framework, but I'm not sure. I'll of course update with more code or answer questions, if needed.