4

I have a UIScrollview embedded in a NavController, both dragged out in the iOS6 storyboard. In my scrollViewController viewDidLoad, I programatically add a UIImageView and keep a property for the image that goes into that UIImageView.

@interface MyScrollViewController () <UIScrollViewDelegate>

@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (strong, nonatomic) UIImageView *imageView;
@property (strong, nonatomic) UIImage *image;

@end

Dragging out the ScrollView in the storyboard and hooking up the outlet made this a weak property by default, but what is the best practice for the other two properties?

DanWebster
  • 141
  • 1
  • 5

1 Answers1

3

The latest versions of Xcode default to using strong. If you use weak you may end up with compiler warnings about accessing a weak variable multiple times in a given scope. So just use strong for everything unless you have a good reason not to.

Mike Weller
  • 45,401
  • 15
  • 131
  • 151