1

Possible Duplicate:
Properties and Instance Variables in Objective-C 2.0

I wrote the codes below, both worked on xcode 3/ios4 and xcode 4/ios5

#import <UIKit/UIKit.h>

@interface testViewController : UIViewController {

NSString *s;

}
@property (retain ,nonatomic) NSString *s;
@end

the one without variables declaration

#import <UIKit/UIKit.h>

@interface testViewController : UIViewController {



}
@property (retain ,nonatomic) NSString *s;
@end

and

#import <UIKit/UIKit.h>

@interface testViewController : UIViewController {

NSString *s;

}

what is the difference between writing with/without variables declaration

As I know @property means replacing/simplfying the method setter/getter of the property. Does the variable declaration in { } means private property that can not be accessed outside testViewController?

Community
  • 1
  • 1
teriyaki
  • 21
  • 4

1 Answers1

0

When you declare property without related ivar, compiler injects it by default. The one difference is that implicit ivar is invisible in derived classes and outside your class.

onegray
  • 5,105
  • 1
  • 23
  • 29