문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top