Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,669 Points

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