Question

Assuming a new project with ARC enabled is created

@autoreleasepool {
    return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}

and the following declaration

@property (nonatomic) NSString *classDescription;

Why would

@synthesize classDescription;

error out with

"Existing ivar 'classDescription' for unsafe_unretained propery 'classDescription must be _unsafe_unretained"

I thought that with Version 4.2 of Xcode, no retains, releases are needed. Is this not correct?

Please clarify

Was it helpful?

Solution

You need to make it a strong property so that ARC knows it should retain the object.

OTHER TIPS

No retains/releases are needed if you are using Automatic Reference Counting. Is this an existing project or new project? New projects should have ARC enabled by default.

If your project was made before Xcode 4.2, then you can enable it by going to Build Settings, search for Objective-C++ Automatic Reference Counting and tick the box.

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