LinkingObjects Chapter 4

The LinkingObjects example of chapter 4 kinda only works by accident. I put a print statement before the write’s to see if the linked objects property was set before db write, and nothing was (as I kind of expected), however that caused the second print statement (the original one after the write) to show an empty list!

It looks like either this is a “feature” or a real bug (a bug was logged at LinkingObjects empty for newly added objects · Issue #5598 · realm/realm-swift · GitHub with no comments.) So it probably works in the example because the property is “faulted” out until the print statement reads it but if you access it beforehand it stays empty.

As that bug states the issue can be “fixed” by reading back myLittleShop after it gets added in the same write block.

wow, great find! We’ll have to add a note clarifying this behavior in the text, thank you!