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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:17:52+00:00 2026-06-04T20:17:52+00:00

So what is actually the difference between these two versions: @interface Foo : NSObject

  • 0

So what is actually the difference between these two versions:

@interface Foo : NSObject
// A guy walks into a bar.
@property(nonatomic, copy) NSString *bar;
@end

// Implementation file
@interface Foo ()
@property(nonatomic, retain) NSArray *baz;
@end

and

@interface Foo : NSObject
// A guy walks into a bar.
@public
@property(nonatomic, copy) NSString *bar;

@private
@property(nonatomic, retain) NSArray *baz;
@end

As far as my understanding goes, putting the @property in the .m basically means that it is private. Correct me if I am wrong? Also which is the best implementation then? Is it just a coding style/practice?

  • 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-04T20:17:53+00:00Added an answer on June 4, 2026 at 8:17 pm

    The compiler can warn you about things that it knows about.

    When I import your header the compiler can see that Foo has a method called bar and setBar:. This means I can use them both

    [instanceOfFoo setBar:@"some string"];
    
    NSLog(@"%@", [instanceOfFoo bar]);
    

    whereas because I only imported the header – the compiler can only see the header it is not aware that there are also methods baz and setBaz: available, so doing the following will cause the compiler to barf

    [instanceOfFoo setBaz:@"some string"];
    
    NSLog(@"%@", [instanceOfFoo baz]);
    

    I can however still access these properties if I know they exist by using KVC like this without the compiler barfing

    [instanceOfFoo setValue:@"some string" forKey:@"baz"];
    
    NSLog(@"%@", [instanceOfFoo valueForKey:@"baz"]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is actually the difference between these two casts? SomeClass sc = (SomeClass)SomeObject; SomeClass
1.) What's the difference between these two queries, exactly? $( #orderedlist li ) $(
If so, what is the difference between the two? Are there actually two separate
Possible Duplicate: What's the difference between is_null($var) and ($var === null)? PHP has two
Are these actually three different concepts or am I getting jumbled? (I've been reading
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually
I need an XML-serializable dictionary. Actually, I now have two quite different programs that
A quick, fun question - What is the difference between a function declaration in
In my code under GCC I get quite many warnings of these two types.
Given the following two interfaces (these are small examples, not my actual implementation): public

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.