I know that I recently asked a similar question, but I'm still a little unsure of it. The same thing happens in several places.
Instance variable used when self is not set to result [[(super or self) init ...] '
A
- (id)initWithCoder:(NSCoder *)decoder { if (![super init]) return nil; red = [decoder decodeFloatForKey:kRedKey];
IN
- (id)initWithFrame:(CGRect)frame title:(NSString*)str sideUp:(BOOL)up{ if(![super initWithFrame:frame]) return nil; int y; UIImage *img; if(up){ img = [UIImage imageNamedTK:@"TapkuLibrary.bundle/Images/graph/popup"]; y = 5; }else{ img = [UIImage imageNamedTK:@"TapkuLibrary.bundle/Images/graph/popdown"]; y = 14; } background = [[UIImageView alloc] initWithImage:img];
WITH
- (id) initWithFrame:(CGRect)frame { if(![super initWithFrame:frame]) return nil; UILabel *titleBackground = [[[UILabel alloc] initWithFrame: CGRectMake(0, 0, 480, 40)] autorelease]; titleBackground.backgroundColor = [UIColor whiteColor]; [self addSubview:titleBackground]; titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
For block A, this is correct
self = [self init]; if( self != nil ) {
And B and C
- (id) initWithFrame:(CGRect)frame { super = [super initWithFrame:frame] if(super != nil) {
Jules source share