我正在用我的iPhone应用程序解决一些内存问题,我一直在考虑一些基础知识.如果我设置了一个ivar并且永远不会在我的对象的生命周期中使用它,当我在其上调用dealloc时,会导致问题吗?例如
@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
// …Run Code Online (Sandbox Code Playgroud) 我正在阅读Stephen G. Kochan撰写的一本名为"Objective-C编程"的书,第六版.它在第144页上有以下声明,这使我感到困惑:
作为基本C数据类型的局部变量没有默认初始值,因此在使用它们之前必须将它们设置为某个值.
然而,当我有以下代码时,它仍然有效,并显示0:
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
int number;
NSLog(@"%i", number);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
是不是int基本的C数据类型?