how to write Realm nested objects?

Viewed 3072

i have this realm structure:

class DateLog: Object {
    dynamic var date = NSDate()
    let workouts = List<WorkoutLog>()
    let activities = List<ActivityLog>()
}

class WorkoutLog: Object {
    dynamic var name = ""
    dynamic var value = 0
    dynamic var notes = ""
}

class ActivityLog: Object {
    dynamic var name = ""
    dynamic var value = 0
    dynamic var notes = ""
}

how can i add to realm DateLog > WorkoutLog data? (date for DateLog; name, value, notes for WorkoutLog)?

the workflow i'm looking for:

  1. add new record to date log (just a date)
  2. add workout log record for that date (with all details)
  3. add activity log record for that same date
1 Answers
Related