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

  • Home
  • SEARCH
  • 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 7786387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:24:33+00:00 2026-06-01T20:24:33+00:00

I am having a hard time on how to understand the actual use of

  • 0

I am having a hard time on how to understand the actual use of setting a property to variables and objects. I tried to read many tutorials and apple documentation but still i am not able to understand on why we should use a property and why we need to synthesize the property? Considering we declare

@property(nonatomic,retain) NSString *str;

why do we need to declare a property. As far as i understand, we can access string object str through out your class. But why do we need to create a property here?

Can someone please help me out?

  • 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-06-01T20:24:34+00:00Added an answer on June 1, 2026 at 8:24 pm

    Properties are usually used to access instance variables from outside of the class.

    For example, if you have a pointer to your class you can get/set the property like this

    someObject.str = @"some string";
    

    You also have to @synthesize the property, usually like this:

    @synthesize str = _str;
    

    In that snippet, _str is the instance variable that the property sets and gets.

    The properties are essentially just shortcuts for creating accessors (setters/getters).

    For example, a setter using your property would look something like this:

    - (void)setStr:(NSString *)str {
        if(str != _str) {
            [_str release];
            _str = [str retain];
        }
    }
    

    and the getter would look something like this:

    - (NSString *)str {
        return _str;
    }
    

    By creating properties, the previous two code blocks are automatically created for you.

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

Sidebar

Related Questions

I'm having a hard time to understand how I could use binomial and normal
I am having a hard time understanding the nuances of git-fetch. I understand that
I'm having a hard time trying to understand other people's codes here. I would
I'm having a hard time getting Google Charts to understand the datetime format. I
I am having hard time to understand how to make field value unique while
I'm having a hard time understand the process of rounding when I convert a
I've been having a hard time trying to understand PyPy's translation. It looks like
I'm having a hard time trying to understand a problem in my iphone app.
I am having a hard time understand Core Data for cocoa. Now I have
I'm having a hard time deciding which Open Session In View to use: configuring

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.