Quirk with basic data, protocols and readwrite vs. declarations readonly

I came across an odd quirk related to Core Data, a declared protocol, and possibly the LLVM 1.5 compiler. Here is the situation.

I have a Core Data model that, among other things, has two classes: IPContainer and IPEvent, with IPContainer being the parent of the IPEvent. Each object has its own class in the project created using mogenerator. mogenerator generates an additional subclass that simply contains declarations of modeled properties, so the class hierarchy is actually IPEvent> _IPEvent> IPContainer> _IPContainer> NSManagedObject. The IPContainer object has an attribute named "id", which is declared as @property(nonatomic, retain) NSNumber* id;in _IPContainer.h. _IPContainer.m has @dynamic id;in implementation to tell Core Data to generate accessories at runtime

I also have the IPGridViewGroup protocol declared in my project that defines several properties, one of which is the same id property. However, the setter is not needed for classes that implement this protocol, so the property in the protocol is declared as the @property(readonly) NSNumber* id;IPEvent class declares that it conforms to the IPGridViewGroup protocol.

This worked fine using the Clang / LLVM 1.0.x compiler (depending on the version of Xcode 3.2.2), but after switching to Xcode 3.2.3 and Clang / LLVM 1.5 a whole bunch of things changed. First, when compiling the IPEvent class, I get the following warning:

/Volumes/Ratbert/Users/bwebster/Projects/UberProject/iPhotoLibraryManager/IPGridViewGroup.h:19:31: warning: property 'id' requires method 'id' to be defined - use @synthesize, @dynamic or provide a method implementation

Then, when I actually run the program, this prints to the console:

Property 'id' is marked readonly on class 'IPEvent'.  Cannot generate a setter method for it.

Following:

-[IPEvent setId:]: unrecognized selector sent to instance 0x200483900

IPEvent, :

/Volumes/Ratbert/Users/bwebster/Projects/UberProject/iPhotoLibraryManager/IPManagedObject/IPEvent.h:14:40: warning: property 'id' 'retain' attribute does not match the property inherited from 'IPGridViewGroup'

, , , , , ​​ , , , .

, , , :

  • , , readonly, readwrite , ? , readwrite , .
  • , - Core Data. , IPEvent id, , IPGridViewGroup. , , , , readwrite ( _IPContainer) , AFAIK .
  • , , . , , , , .

:, , IPEvent, , -. , , , .

readonly ( ), readwrite, "warning: attribute" readonly "" longitude " " readwrite ", " _IPEvent "" ". , , .

, , , IPEvent getter , " ", .

+3
3

, , , , ​​ , , , , .

, . , .

. @property , . , , . , - .

- , , #import .

, , IPContainer : , - getter. , ? , readonly readwrite. , , , .

1 , , , readonly, readwrite , , ?

"". ? . , readonly getter, setter. , setter , .

, , , NSManagedObject. , , .

2 , IPEvent 'id' , IPGridViewGroup .

, , .

3 , , -. , , .

(1) , . , . (2) readwrite , .

, , IPEvent , " ", .

, , . , , " ". ? " , readonly, , , readwrite ?"

, . , .

, . , ? - . .

, ( ) "... , ".

+4

. :

  • IPEvent - , _IPEvent IPGridViewGroup.
  • IPGridViewGroup readonly id.
  • _IPEvent readwrite id _IPContainer.

, (, , , ), IPEvent id, readonly .

id IPEvent readwrite?

:

@property (nonatomic, retain, readwrite) NSNumber *id;

, .

0
@property(readonly) NSNumber* id

. Core Data docs , nonatomic ( ), , , ( ).

ivar , @dynamic, , . , .

, , :

http://openradar.appspot.com/8027473 The compiler forgets about ivar superclass exists if support is declared without ivar

It is also possible that the identifier has special meaning in Core Data, and you must use a different name.

0
source

Source: https://habr.com/ru/post/1751493/


All Articles