You can't do this because Swift Arrays are structs, not classes. If you want to have a weak reference to an array in Swift, you will need to use a wrapper object like so:
class Wrapper<T> {
let value: T
}
then change your class to the following:
class Session {
weak var sets: Wrapper<[ExerciseSet]?>
}
That being said, it probably doesn't make sense to use a weak reference here. Your session is probably either a singleton or an object that stays in memory your entire application lifecycle.
Unless you actually need to know whether the property was set or not, you can also probably use [ExerciseSet]
instead of making it optional, then use an empty array when you don't have any values.