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 Object-Oriented Swift Classes and Objects Classes and Their Methods

help , I just do not know hat to do


class Button {
  var width: Double
  var height: Double

  init(width:Double, height:Double){
    self.width = width
    self.height = height


1 Answer

Felix Ayala
Felix Ayala
5,541 Points

Hi Marcos,

The challenge clearly says that you need to add a method named incrementBy which will accept a parameter named points. (Within the method add points to the width and height properties).

So, in order to create a method inside your class, you must declare a function tha receives a Double parameter named points, then, increment your width and height properties by your new parameter.

Your code will looks like:

func incrementBy(points: Double) {
    self.width = self.width + points
    self.height = self.height + points