1

as i see the answer Visit IBOutlet and IBAction

the highest voted answer said “If you're not going to be using Interface Builder at all, then you don't need them in your code”

i fill confused when i see somebody's code like this

#import <UIKit/UIKit.h>

@interface ParallaxHeaderView : UIView
@property (nonatomic) IBOutlet UILabel *headerTitleLabel;
@property (nonatomic) IBOutlet UIImageView *headerImageView;

@end

are there any tips beyond my shallow knowledge?

Community
  • 1
  • 1
alfred zh
  • 51
  • 4
  • 1
    So are these really views that the `ParallaxHeaderView` is adding programmatically rather than via IB? If so, then the `IBOutlet` is unnecessary (though no harm done other than being somewhat misleading). That quote you reference from that other question is correct. – Rob Feb 04 '15 at 04:04

1 Answers1

1

Sometimes when the code might be used in other projects, the developer will provide the ability for the end user to choose the default programmatic interface, or design her own interface in IB.

Since distinct initialization methods (initWithFrame:, initWithCoder: etc..) will be triggered based on whether the code is called programmatically or through IB, one can provide such options.

But I agree that it's a rather special use case.

Rikkles
  • 3,372
  • 1
  • 18
  • 24