Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Objective-C automatic property synthesis for a class?

I am writing a wrapper class that uses the dynamic runtime to forward messages to the wrapped object, using forwardInvocation:

However the type checker now complains that the methods aren't implemented on my wrapper class, which is generally a good thing.

So I thought I'd write some method declarations in the header of my wrapper to satisfy the type checker. Note that I just want the declarations, not the definitions.

However, when I copy over my @property directives, they are not just declared, but defined as well, and in this way they take precedence over the method forwarding, and so it breaks the forwarding.

So is there a way to declare a @property and not have it automatically synthesize getters and setters? I love this feature so I'd want to disable on a per class basis only, and leave it on for the rest of the project. A bit like -fno-objc-arc.

P.S. clang -v => $ Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)

like image 846
lmirosevic Avatar asked Jun 25 '13 10:06

lmirosevic


1 Answers

If you add

@dynamic yourProperty;

to the class implementation then no instance variables and no accessor functions will be synthesized for that property.

like image 174
Martin R Avatar answered Oct 12 '22 12:10

Martin R