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 8720181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:58:31+00:00 2026-06-13T06:58:31+00:00

What the difference between declaring an @property in .h or .m file @property (nonatomic,

  • 0

What the difference between declaring an @property in .h or .m file

@property (nonatomic, readwrite, assign) BOOL notificationDidLaunch;

Is it to do with the scope of the variable?

Also in the .h file whats the difference between declaring a string with the brakets like so

@interface AppDelegate : NSObject < UIApplicationDelegate > {
    NSString *hat;
}

and doing it outside of them like below

@property (nonatomic, strong) NSString *hat;
  • 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-13T06:58:32+00:00Added an answer on June 13, 2026 at 6:58 am

    As Tiago says, putting an @property declaration inside a class extension in the .m (implementation) file, is a way to make the property private so only the class itself can access it. When declared in the .h (public interface file), it is visible to all code that imports that .h file. Keep in mind that @properties are really just a convenience for declaring and synthesizing accessor methods, and as with all methods in Objective-C, they’re never truly private. The best you get is a compiler warning that no public interface declares the method in question if you try to use a non-public method in another class.

    For the second part of your question, this declares an instance variable (“ivar”) called myString:

    @interface MyClass : NSObject
    {
        NSString *myString;
    }
    

    While this declares a property called myString:

    @property NSString *myString;
    

    The difference between an instance variable and an @property is more significant than just saying that an ivar is accessible only by your class’s instances. Declaring an ivar adds a variable to a class’s structure in memory. In contrast, @properties declare/define methods on a class. By default, these methods set/get the value of an associated, and similarly named ivar, but that’s not a requirement, and it is perfectly acceptable and quite common to have methods for an @property that don’t access an ivar directly. Say for example a class that has a firstName and lastName properties backed by _firstName and _lastName ivars, along with a third, fullName property that simply concatenates the value returned by the firstName and lastName getter methods together (and/or splits a two part name in its set method).

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

Sidebar

Related Questions

Please can any one tell me whats the difference between declaring a variable inside
What is the difference between declaring a variable with this or var ? var
Is there a difference between declaring a static variable outside of a function and
In Objective-C, what's the difference between declaring a variable id versus declaring it NSObject
When declaring a string in C what is the difference between char* mystring; and
Possible Duplicate: Is there a difference between an instance variable and a property in
When declaring a function, what is the difference between the parameters string* and string&
Duplicate Whats the difference between declaring as new and as something new something i
I am wondering at the difference between declaring a variable as volatile and always
In PHP, What is the difference between declaring methods inside class like public function

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.