Xcode Warning: “Property '<x>' and its super class '<y>' don't have matching 'atomic' atrribute”

StackOverflow https://stackoverflow.com/questions/4092804

  •  28-09-2019
  •  | 
  •  

Question

I'm getting an Xcode warning when compiling several class that subclass existing Cocoa classes. For example, the following class

   @interface HMAttitude : CMAttitude
    {
        double pitch;
        double roll;
        double yaw;
    }

    @property (readwrite) double pitch;
    @property (readwrite) double roll;
    @property (readwrite) double yaw;

    @end

-

@implementation HMAttitude

@synthesize pitch, roll, yaw;

- (id) init
{
    return [super init];
}

@end

yields three warnings

warning: property 'yaw' and its super class 'CMAttitude' don't have matching 'atomic' attribute

warning: property 'pitch' and its super class 'CMAttitude' don't have matching 'atomic' attribute

warning: property 'roll' and its super class 'CMAttitude' don't have matching 'atomic' attribute

All of the subclasses in question are required in order to create CMMotionManager and CLLocationManager subclasses capable of acting like the superclasses, only loading their data from a csv file. The only reason that I am subclassing them is to gain access (or override) their read-only properties. Without the ability to set these properties, I have no way of returning the same objects as the real CMMotionManager and CLLocationManager classes.

Currently everything works fine aside from having to use a #pragma to ignore the warning which slightly bothers me.

Does anyone know why this warning is being generated? Given the properties aren't being set to nonatomic (atomic is the default), I have no absolutely no clue.

Is there anything that I need to explicitly do in order for these properties to be atomic?

Was it helpful?

Solution

The error message is slightly confusing—if you look at the definition of those properties in the CMAttitude documentation, you'll see that they're actually declared as non-atomic. So, you should declare your properties as non-atomic as well.

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