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 Object-Oriented Swift Class Inheritance Creating a Subclass

Michael Lovich
Michael Lovich
6,422 Points

Concepts and Big Picture

I'm having trouble understanding conceptually all that we have discussed. I've followed along, I can copy and understand what is being written, but I'm having trouble generating the code myself. Is there a "big picture" review video I can watch than can help me know why and when to use certain lines of code?

1 Answer

Matthew Long
Matthew Long
28,379 Points

I don't think there is a review video. Sometimes Pasan has a video at the end of a course that's roughly 3 minutes long that discussed what you should take away from a course.

If you're taking notes the best way to review the videos is to just read over your notes. You can also rewatch the videos. I do this sometimes. I always change the speed to at least 1.5x after watching the first time, because I'm better at catching on the second time through.

The best way at getting better at knowing how to write the code on your own is just practicing. In my experience you can't really learn something until you've given it some practice. This means you may need to create projects, make things up in the playgrounds, toy around with some of the code Pasan writes.

In case you're having trouble with subclasses you can just think of it as an extension of an already existing class. It's like basing a new class off of an existing class. For example, all vehicles have some properties, but not all vehicles are the same. There are also trucks, bikes, etc. These vehicles share some properties but not all of them. But all cars, in this example, have 4 seats so we can set that as the default value.

Hopefully that cleared things up and didn't make it worse.

class Car: Vehicle {
  var numberOfSeats: Int = 4

let someCar = Car(withDoors: 2, andWheels: 4)

Happy coding! :smile: