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 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?