I would have more information about ARC and weak and strong reference :
Actually, if I have :
@interface
@property (weak) IBOutlet UIButton * button
@property (weak) UIView *subview
@end
@implementation
-(BOOL) viewDidLoad
{
UIView *aSubView= [[UIView alloc]....];
[self.view addSubview:aSubview];
self.subview = aSubview;
}
It's normal to have weak reference for the button because its superview have a strong reference on it.
Now, I add UIView
programmatically, I also put a weak reference because when I will add this subView in a superview, there will be a strong reference. First question : Is this a good method ?
Now my real problems are on the second source code with the collection. What can I put with IBOutletCollection
?
And if I want to keep an array of views which are added programmatically I can't because NSArray
keep strong reference and views' superview too so there will be some leaks . How can I have a NSArray
of my subviews without leaks ?
@property (?) IBOutletCollection .....
@property (?) NSArray *subviews
-(BOOL) viewDidLoad
{
?
}