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!

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 Swift 2.0 Protocols Creating Flexible Objects Using Protocols Protocol Inheritance

Justin Janes
Justin Janes
5,904 Points

I have this same code snippet open in Xcode with no errors or warnings and the preview button isn't showing any compiler

I've tested this out in Xcode and I don't see any errors or warnings there - I've tried treating the inheritance by assigning the variables to self.cuddlyName etc. but that results in errors. I've re-watched the video but the video focuses on implementing inheritance of functions not simply variables inside of a struct.

protocol AnimalType {
    var numberOfLegs: Int { get }

protocol PetType: AnimalType {
    var cuddlyName: String { get }


struct dog: PetType {
    var cuddlyName = "Boba"
    var numberOfLegs = 5


1 Answer

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

Oh you're going to love this! Your code is fine. This is an example of the challenge being picky. You named your struct dog. It wants the struct to be named Dog. Note the capitalization. If I take your code and copy/paste it into the challenge and make that tiny change, your code passes! Happy coding! :sparkles: