Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iphone中的内存管理_Iphone_Cocoa Touch - Fatal编程技术网

iphone中的内存管理

iphone中的内存管理,iphone,cocoa-touch,Iphone,Cocoa Touch,我有一个类,其中定义了一个数组作为保留属性,例如: @属性(非原子,保留)NSMUTABLEARRY*temp 我可以使用self.temp=self.temp; 如果是,任何一个都可以告诉setter方法来解决这个问题,并逐步实现这个问题吗 从这里展望未来 如果需要setter方法,请在头文件中声明NSMutableArray,谢谢: { NSMutableArray *temp; } @property(nonatomic, retain) NSMutableArray *temp

我有一个类,其中定义了一个数组作为保留属性,例如:

@属性(非原子,保留)NSMUTABLEARRY*temp

我可以使用self.temp=self.temp; 如果是,任何一个都可以告诉setter方法来解决这个问题,并逐步实现这个问题吗 从这里展望未来


如果需要setter方法,请在头文件中声明
NSMutableArray

,谢谢:

{
    NSMutableArray *temp;
}

@property(nonatomic, retain) NSMutableArray *temp;
然后在主文件中,确保在
@implementation MyClass
之后调用它:

@synthesize temp;

这为您提供了getter和setter方法,因此您可以在此类之外调用
MyClass.temp=

为什么要使用self.temp=self.temp?如果我们这样做,那么会发生什么呢?(void)setVarid:(id)newValue{If(var!=newValue){[var release];var=newValue;[newValue retain];}这种情况会发生什么。}如果你写self.temp=self.temp,那么什么都不会发生。-(void)setVarid)newValue{If(var!=newValue){[var release];var=newValue;[newValue retain];}}这将是setter方法,请告诉我这将如何一步一步地实现。很抱歉,这没有任何帮助!我甚至怀疑它会被编译。您不需要创建自己的setter方法。只需使用我在答案中发布的内容!