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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:45:22+00:00 2026-06-08T20:45:22+00:00

code1 @interface Rectangle : NSObject { int width,height; } @property int width,height; code2 @interface

  • 0

code1

@interface Rectangle : NSObject   
{
    int width,height;
}
@property int width,height;

code2

@interface Rectangle : NSObject
@property int width,height;
{
    int width,height;
}

Can anyone tell me, what is different between them? And in @property I already put int for width and height. Why do we need to declare it again in curly brackets?

Update:
I am using osx 10.8 64bit.

  • 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-08T20:45:25+00:00Added an answer on June 8, 2026 at 8:45 pm

    In your example “code1” is correct but possibly unneeded, while “code2” is incorrect and won’t compile. Any instance variables need to be declared in curly brackets directly after the @interface line which is why the second example is wrong.

    As some others has mentioned you may not need to declare width and height at all. If you are using the modern runtime the compiler can tell from the @property statement that you meant to have an underlying instance variable for the property and will create these for you. On the other hand with the older legacy runtime the instance variables like width and height must be explicitly declared. You didn’t specify your platform so it is no clear if it is needed in your case.

    The modern runtime is always used on iOS, which is why many people here will tell you incorrectly that the instance variables do not need to be declared in any case. On Mac OS X the modern runtime is used with 64-bit code in 10.5 or newer. If you are using 32-bit code or an older version you need to explicitly declare your instance variables.

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

Sidebar

Related Questions

This is my code: @interface Object : NSObject { @private NSArray *array; } @property
Please look at this code: @interface myObject:NSObject -(void)function:(id)param; @end @implementation myObject -(void)function:(id)param { NSLog(@BEFORE);
Assume that I have this piece of code: @interface Foo : NSObject { Bar
First off, my code: @interface Block : NSObject { NSData *data; NSInteger slice_count; }
It seems JAXB can't read what it writes. Consider the following code: interface IFoo
Using Delphi 2007 I can write the following code: interface TTestType = (ttTest1, ttTest2);
Here's my code: @interface Game : Layer // this is from cocos2d { int
still have problem with this part of code: @interface MYAccessMp3Tags: NSObject { NSTimeInterval duration;
I've seen a lot of codes that do this: @interface Test0 : NSObject {
In my AppDelegate.h file i written the following code @interface iBountyHunterAppDelegate : NSObject <UIApplicationDelegate>

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.