Can I just check what is happening when you do the following (See below), I am right in thinking that no iVars are created in "INTERFACE" just three properties. In the "IMPLEMENTATION" those three properties are assigned to iVars called _window
, _animationTimer
& _currentFrame
which are created by the @synthesize
command?
// INTERFACE
@interface testDelegate : NSObject ... {
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, assign) NSTimer *animationTimer;
@property (nonatomic, assign) int currentFrame;
...
.
// IMPLEMENTATION
@implementation testDelegate
@synthesize window = _window;
@synthesize animationTimer = _animationTimer;
@synthesize currentFrame = _currentFrame;
...
Yep, that's how it works. @synthesize
can now automatically generate the appropriate instance variables as well as accessors for them. It's a relatively recent development in the language.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.