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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:51:06+00:00 2026-06-01T10:51:06+00:00

Some Obj-C instruction use variables in an extension vs having them as an ivar.

  • 0

Some Obj-C instruction use variables in an extension vs having them as an ivar.
Please someone explain the difference? (and better practice for this)

@interface myClass
{
int myVar;
}

VS

@interface myClass(){
int myVar;
}

This is especially the case for the Stanford IOS online course.
I don’t understand why they do this instead of just using the @private in the interface (non extension).

Thank you!

  • 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-01T10:51:07+00:00Added an answer on June 1, 2026 at 10:51 am

    As far as I know, when you give someone access to an API you have written, you need to give them the .h file. Therefore the ivars which are private can still be seen by someone who should not care about them. When you put them into the .m file they are completely hidden and really private.

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

Sidebar

Related Questions

Some of Apple's obj-c API's still use C functions, e.g.: -(NSArray * ) sortedArrayUsingFunction:
As the title mentioned, I want to encode a Image Obj into some kind
//obj C version, with some - less than one second on 18,000 iterations for
Here's some example code: class Obj attr :c, true def == that p '=='
Made a custom obj called Item with some string fields and one float. .h
Our framework requires wrapping certain functions in some ugly boilerplate code: def prefix_myname_suffix(obj): def
If I have some R list mylist , you can append an item obj
Can I get the value of an object field some other way than obj.field
I've been reading some Obj-C projects, and I'm always finding this standard for naming
obj.update_attribute(:only_one_field, 'Some Value') obj.update_attributes(field1: 'value', field2: 'value2', field3: 'value3') Both of these will update

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.