Domanda

I have in .h:

@property (nonatomic,retain) NSString *myString;

In .m:

@synthesize myString;
myString =@"Test";

Do I have to release it in dealloc?
Because sometimes my app crashes due to [myString release], not sure why?

È stato utile?

Soluzione

As long as the property is defined with the "retain" attribute, it needs to be released in the dealloc.

ARC (Automatic Reference Counting) in modern Objective C has built-in garbage collection, so releasing and retaining are no longer necessary.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top