Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7049335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:00:04+00:00 2026-05-28T03:00:04+00:00

I am just learning OOP from a book I picked up (Big Nerd Ranch),

  • 0

I am just learning OOP from a book I picked up (Big Nerd Ranch), and it just went through the getter and setter chapter. I would just like to clarify I understand what I have just done. Instead of creating a method to set the value of an instance, and then another method to extract the value and display it, I create use the @property and @synthesize syntax to define both methods.

Instead of doing this:

-(void) setHeightOfObject:(int)h;
-(void) setWeightOfObject:(float)w;
-(int) heightOfObject;
-(float) weightOfObject;

and defining it like this:

- (int)heightOfObject
{
    return heightOfObject;
}

- (void)setHeightOfObject:(int)h
{
    heightInMeters = h;
}

- (float)weightOfObject
{
    return weightOfObject;
}

- (void)setWeightOfObject:(float)w
{
    weightOfObject = w;
}

I would do this with getter and setters in the .h file:

@property int heightOfObject;
@property float weightOfObject;

And then go to my .m file and link it:

@synthesize heightInMeters, weightOfObject;

This then gives me the ability to set the value of my object, and then get it if I need it printed? I know this is an important concept and I want to make sure I have the proper grasp of it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:00:05+00:00Added an answer on May 28, 2026 at 3:00 am

    You are correct. The @synthesize essential expands out to the implementation you wrote while compiling.

    Since writing getters and setters is boring and repetitive (and most objects have a bunch of properties you’d want getters and setters for) having this little shortcut makes you spend less time on boilerplate code and more time implementing something interesting.

    If you’d like more detailed information about objective-c’s properties, you can have a look at the programming guide (although this might be somewhat unnecessarily detailed for you at this point).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started learning Objective-C and OOP ... so I have very stupid question
Just learning CakePHP and its Bake feature. I tried to run ../cake/console/cake bake from
Just learning Silverlight 4/RIA and i 'm stuck in a weird problem: setup an
Im just learning mod_rewrite and regex stuff, and what I'm trying to do is
Im just learning SQLite and I can't get my parameters to compile into the
I am just learning about app.config in respect of creating custom sections. I have
I'm just learning Ruby on Rails. I've read a few books, I've watched lots
I'm just learning to work with partial classes in VB.NET and VS2008. Specifically, I'm
I'm just learning about SVG, and it seems great but I'm not sure about
I'm just learning Perl. When is it advisable to use OO Perl instead of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.