Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Intermediate Swift Memory Management in Swift Memory Leaks

Aananya Vyas
Aananya Vyas
20,157 Points

code snippet missing :/

cant find the code snippet you mentioned in the lecture in teachers notes.. please update??!!

Greg Weiss
Greg Weiss
14,135 Points

Here is the snippet:

class Person {
    let name: String
    var apartment: Apartment?

    init(name: String) {
        self.name = name
    }

    deinit {
        print("\(name) is being deinitialized. Memory deallocated")
    }
}

class Apartment {
    let unit: String
    var tenant: Person?

    init(unit: String) {
        self.unit = unit
    }

    deinit {
        print("Apartment \(unit) is being deinitialized. Memory deallocated")
    }
}

1 Answer

Dan Poynor
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Dan Poynor
Data Analysis Techdegree Graduate 62,951 Points

20180710 update - Clicking on the Downloads tab then opening the IntermediateSwift.playground file you'll find the snippets for each lesson.