大佬教程收集整理的这篇文章主要介绍了objective-c – Obj-C,’self’未设置为'[(super或self)init …]的结果时使用的实例变量,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
‘self’时使用的实例变量未设置为'[(super或self)init …]的结果
- (id)initWithCoder:(NSCoder *)decoder { if (![super init]) return nil; red = [decoder decodeFloatForKey:kRedKey]; //occurs here green = [decoder decodeFloatForKey:kGreenKey]; blue = [decoder decodeFloatForKey:kBlueKey]; return self; }
乙
- (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]; // occurs here
C
- (id) initWithFrame:(CGRect)frame { if(![super initWithFrame:frame]) return nil; UILabel *titleBACkground = [[[UILabel alloc] initWithFrame: CGRectMake(0,480,40)] autorelease]; titleBACkground.BACkgroundColor = [UIColor whiteColor]; [self addSubview@R_139_6964@BACkground]; titleLabel = [[UILabel alloc] initWithFrame:CGRectZero]; // occurs here
对于块A,这是正确的
self = [self init]; if( self != nil ) {
和B& C
- (id) initWithFrame:(CGRect)frame { super = [super initWithFrame:frame] if(super != nil) {
以上是大佬教程为你收集整理的objective-c – Obj-C,’self’未设置为'[(super或self)init …]的结果时使用的实例变量全部内容,希望文章能够帮你解决objective-c – Obj-C,’self’未设置为'[(super或self)init …]的结果时使用的实例变量所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。