12

I was converting a code from non-ARC to ARC, and removing some unnecessary @synthesize calls. One specific class started issuing warnings for some properties:

Class.h

@property (strong, nonatomic) NSString *xyz;

but when building, I get the warning.

Property 'xyz' requires method 'xyz'to be defined - use @synthesize, @dynamic or provide a method implementation in this class implementation

I thought that using Xcode 4.6 and and Default Apple LLVM compiler 4.2, the @properties should be auto-synthesized.

How do I tell the compiler to auto-synthesize the property? Do I have to use a specific project configuration to remove this warning?

4

1 回答 1

38

Is this property on an NSManagedObject subclass? NSManagedObject disables auto-synthesis precisely because most declared properties are expected to be @dynamic.

This is accomplished with the NS_REQUIRES_PROPERTY_DEFINITIONS macro placed right before the @interface NSManagedObject, which expands to __attribute__((objc_requires_property_definitions)). This could be used on other classes too, but NSManagedObject is the only framework class I know of that does this.

于 2013-02-19T18:03:14.810 回答