Created
January 6, 2012 23:30
-
-
Save boredzo/1572986 to your computer and use it in GitHub Desktop.
Initialization code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface AutoScrollView () | |
- (id) commonInit __attribute__((objc_method_family(init))); | |
@property(nonatomic, assign, getter=isAutoScrolling) BOOL autoScrolling; | |
@property(nonatomic, retain) NSTimer *autoScrollTimer, *delayedStartScrollingTimer; | |
@property(nonatomic, retain) UIGestureRecognizer *tapRecognizer; | |
@end | |
@implementation AutoScrollView { | |
BOOL autoScrollWasDelayed; | |
} | |
@synthesize autoScrolling; | |
@synthesize autoScrollTimer, delayedStartScrollingTimer; | |
@synthesize tapRecognizer; | |
@synthesize delegate; | |
- (id) commonInit { | |
//(With the init attribute) Analyzer: Instance variable used while 'self' is not set to the result of '[(super or self) init...]' | |
tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toggleAutoScrolling)]; | |
[self addGestureRecognizer:tapRecognizer]; | |
return self; | |
} | |
- (id) initWithCoder:(NSCoder *)decoder { | |
if ((self = [super initWithCoder:decoder])) { | |
self = [self commonInit]; | |
} | |
//(If commonInit does not have the init attribute) Analyzer: Returning 'self' while it is not set to the result of '[(super or self) init...]' | |
return self; | |
} | |
- (id) initWithFrame:(CGRect)frame { | |
if ((self = [super initWithFrame:frame])) { | |
self = [self commonInit]; | |
} | |
//(If commonInit does not have the init attribute) Analyzer: Returning 'self' while it is not set to the result of '[(super or self) init...]' | |
return self; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why not do
-(void)commonInit
instead? Or even do it with a static function if you want to avoid subclasses breaking you.