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 Complex Data Structures Adding Instance Methods

Dzmitry Matsiulka
Dzmitry Matsiulka
1,075 Points

My code cannot be compiled but the output doesn't show anything.

It compiles in xCode, however it does nothing in the treehouse editor. Could anyone help me please.

2 Answers

Jaroslaw Adamowicz
Jaroslaw Adamowicz
11,634 Points

Hi there,

it is hard to tell you what went wrong without having your input :)

But let's get you up to speed:

1) First part of challenge you simply need to add method in Person class (before last curly brace). This method can look like this one:

  func fullName() -> String {
    return firstName + " " + lastName

2) Second part of this challenge requires you to create 2 constants. First is aPerson (so you need to use initializer) and then myFullName for which you only need to use aPerson object and call method you did created in 1st part.

So, here is aPerson

let aPerson = Person(firstName: "John", lastName:"Smith")

and here is a myFullName :

let myFullName = aPerson.fullName() 

NOTE: you can use another name than "John Smith", that is only for example :D

I hope now it all compiles and you can continue your learning journey!

Cheers! Jarek

Where’s your code example?