Having difficulty retrieving object properties with relation to their parent categories


#1

I am new to realm and iOS development so I apologize in advance if something isn’t explained properly or is just incorrect.

I have 2 Realm Object classes:

class Category: Object {

@objc dynamic var name: String = ""
@objc dynamic var color: String = ""
let trackers = List<Tracker>()

}

and

class Tracker: Object {

@objc dynamic var timeSegment: Int = 0
var parentCategory = LinkingObjects(fromType: Category.self, property: "trackers")

}

The issue is that I’m able to store new timeSegment properties consistently; however, I cannot retrieve & display a collection of timeSegment values from their parentCategory.

Any help is appreciated, and can follow up with any additional details.


#2

How do you store the new data?
You should add to the Category.trackers list. With this way, you should able to get the parentCategory.


#3

thanks for the response, i just now was able to solve it adding a new property to Tracker class referencing parent property name, and filtering results based on that. appreciate your help!