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 Objective-C Diving Deeper - Classes, Properties and Methods Creating Methods!

how to specify method return type

How to specify return type as float?

float subtotal;

  [self.subtotal = self.subtotal * 0.2];
return float;

1 Answer

james south
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

the return type goes where you have void. replace void with float. void methods operate by side-effect and do not return anything. instead of subtotal*, put float - that is the type of the argument given to the calculateTip method (edit - that may be acceptable, i'm just describing what worked for me to pass this challenge). in the body, use a new internal variable, like tip, and set it equal to subtotal * 0.2. finally, return tip. your last curly brace must come after the return statement, not before.