@interface testClass { ID myobject;}@property (nonatomic,retain) ID myobject;@end@implementation testClass@synthesize myobject;- (ID)init { ... // Do I have to set myobject to nil here? // So if myobject isn't used the dealloc call to nil // will be okay? Or can you release the variable without // having set every object to nil that you may may not use ...}...// Somewhere in the code,myobject may be set to// an instance of an object via self.myobject = [AnObject grabAnObject]// but the object may be left alone...- (voID)dealloc { [myobject release]; [super dealloc];}@end解决方法 初始化程序运行之前的实例变量 are initialized to 0 总结
以上是内存溢出为你收集整理的iphone – 实例变量默认设置为nil在Objective-C?全部内容,希望文章能够帮你解决iphone – 实例变量默认设置为nil在Objective-C?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)