Access iOS Xcode 4 Properties

I recently switched to Xcode 4, and I don't really understand this new way to write accessors. For example, in the delegation class of the application, which is automatically generated when a new project is created, the object is windownot declared in @interface, but only as follows:

@property (nonatomic, retain) IBOutlet UIWindow *window;

Then in the implementation file we have @synthesize window=_window;. And in functions we have self.windowOR _window.

For instance:

[self.window makeKeyAndVisible]; // in didFinishLaunchingWithOptions function
[_window release]; // in dealloc function

Can you explain to me the difference, why @interfacethere is nothing, why we do @synthesize window=_window;instead @synthesize window;and what is the difference between self.windowand _window, I mean, when I need to call another, than another?

I got a little lost and feel that the new code I'm doing is trying to do the same thing that does not work properly ...

Thank!

+5
2
  • " @interface" "

    - ivar .

  • " @synthesize window=_window;

    , window ivar _window ( ivar )

  • " self.window _window?"

    window "getter" (.. foo = [self window]), ivar .

  • " ?"

    , dealloc, , ivar .

+16

Xcode 4. Objective-C 2.0 ( Xcode 4 ).

Objective-C ,

"-" . , , , .

+2

All Articles