Beomseok
Beomseok

Reputation: 471

why declare Object in @interface When used @property In Xcode 4

@interface first : <NSObject> {
   NSString *myStr;
  /**
       I don't understand why declared this NSString *myStr.
       Even if not declare NSString *myStr, this codes work well.
  **/
}
@property (nonatomic, retain) NSString *myStr;

and Add @synthesize to first.m

Is it correct that I don't need to declare myStr as an instance variable if I always use the myStr property, i.e. self.myStr?

Upvotes: 3

Views: 1496

Answers (2)

Tomas Vana
Tomas Vana

Reputation: 18775

In the modern runtime (with a reasonably recent version of xcode, simulator etc.) it makes no difference because the compiler generates it for you.

Note that with the newest version of LLVM you don't even need the synthesize ;)

Upvotes: 3

Inder Kumar Rathore
Inder Kumar Rathore

Reputation: 39978

if you are using LLVM compiler then declaring instance variable who's property is declared is optional as the compiler creates automatically

Upvotes: 0

Related Questions