Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top