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 Blog Reader iPhone App Data Modeling Creating a Custom Class: Part 1

Areeb Bajwa
Areeb Bajwa
5,638 Points

Setting using the getter method!?

Near the end of the video, Amit assigns a value to blogPost.title which supposed to be a getter method which simply "returns" the title. Is this a mistake? He later adds that you can also do [blogPost setTitle:...] which seems to be the only correct way to me.

1 Answer

Hello Areeb,

Objective-C can be a bit confusing. Both [blogPost setTitle:@"Something useful."] and blogPost.title = @"Something useful." accomplish the same thing. It is merely a programming style like curly braces:

- (void)someMethod {

}

Or

- (void)someMethod
{

}

Both examples are valid method signatures just as the two different styles of using setters.

Choose one and be consistent and your good to go :)