Basically I want to be able to access the UIApplication delegate's window
property all the way through my class, so I want to reference it with an iVar.
To this end I don't want to "own" it, just reference it.
So therefore should I just put a variable reference in the .h file?
#import <UIKit/UIKit.h>
@interface MessageView : UIView {
UILabel *messageLabel;
UIWindow *window;
}
@property (nonatomic, retain) UILabel *messageLabel;
@end
Or should I set the property there too?
I'm sceptical because the property would be nonatomic, retain
, but I don't want to retain it, unless I actually do and I'm just being thick! :p
The purpose of having the window object is just to be able to add subviews to it, rather than the current view controller's view.
Thanks
Why not use
@property (nonatomic, assign) UIWindow *window
Then you are not retaining it.
Given the window should exist for the lifetime of your app there is no real need to retain it as it's already being retained by your app delegate.
Having a property in the first place in this scenario is nothing more than syntactic sugar
someclass.window = self.window; // Using a property
is much more succinct than
window = [UIApplication sharedApplication].window; // Using an iVar