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 Build a Simple iPhone App with Objective-C Improving Our User Interface Adding a Pop of Color

Return type for a method syntax

When specifying the return type for a method in Objective-C, why is an * included in the parenthesis with the return type? What does the * denote?

For example,

  • (UIColor *)randomColor;

Why include the *?

1 Answer

Gabe Nadel
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Gabe Nadel
Treehouse Guest Teacher

The * denotes a pointer. Pointers are a key concept that often get ignored by developers for one reason or another. They can be a bit tricky, so best to read-up on them, pu them to use and circle back to keep building that understanding.

Here's a good write-up on Pointers, you'll want to scroll down to see the sections on pointers.

http://rypress.com/tutorials/objective-c/c-basics

I appreciate the answer, and the link to the tutorial. Always good to read-up on the basics. I suppose what threw me off was the fact that the syntax was simply a *. I'm accustomed to seeing *pointer or *thing...essentially the * has a word that follows it. So, now I'm curious why the * is allowed to be on it's own when declaring a return type. Perhaps this is simply a syntax that I just need to remember and move on from.