我感到困惑,在iOS5中使用ARC时,我应该使用弱或强关键字声明我在视图中创建的子视图的引用。
以下是我的头文件示例:
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
@class SCLGridView;
@interface MyViewController : UIViewController <UIPopoverControllerDelegate, MFMailComposeViewControllerDelegate>
@property (weak, nonatomic) IBOutlet UIView *hiddenBrowserView;
@property (strong, nonatomic) SCLGridView *gridView;
@property (strong, nonatomic) UIImageView *backgroundView;
@property (strong, nonatomic) UIView *backgroundShadowView;
@property (strong, nonatomic) UIPopoverController* popOverController;
@end
我的印象是,我正在创建并想要引用的视图应该使用强关键字声明,因为我拥有这些视图(我创建它们)。但是我已经将hiddenBrowserView声明为弱,因为我引用了我在故事板中创建的视图。这个apporach是正确的还是我应该使所有那些视图引用为弱,即使对于我以编程方式创建的视图的引用?谢谢!
答案 0 :(得分:2)
据我所知,控制器的主视图强烈引用了子视图。因此,没有任何目的可以强烈地引用它们,因为当主视图出现故障时它们将毫无用处。