Does @interface with properties only require @implementation?

92 views Asked by At

I would like to define a C struct-like in my Objective-C header file which includes _ivars only, however, since this a header file only there would be no corresponding @implementation. Is that even possible? (I also don't want to force the header file includers to add @implementation since this is a simple descriptor definition)

I would like it to be @interface definition so users who like to extend it and add more data members to it could do so (again, only _ivars). However, other suggestions might work if you think of something.

1

There are 1 answers

6
bbum On BEST ANSWER

Yes, there has to be an @implementation declared for the class that is compiled by the compiler to cause the class to be realized at runtime (including the storage backing the @property declarations.

Once compiled, that class cannot extended with additional @properties that are automatically backed (it can be extended via categories, but you're on your own for storage and categorical extensions of classes is generally not recommended anyway).