Reputation: 368
I just want to get a clear answer on this before I spend any more time: I'm messing around with writing preprocessor macros to simplify synthesizing Objective-C properties. One idea I've seen is something like #define SYNTHESIZE(_X_) @synthesize _X_ = _##_X_
, which binds a property to a similarly named instance variable with an underscore prefix.
In trying to take this further, my question is, would I be able to call ever call @synthesize with a property name, but get this property name indirectly? For instance, if I do some class introspection to find the names of all the properties through a class, would it be possible to pass one of these into @synthesize, or does it have to be the actual name itself? If it's of any use, I'm compiling with LLVM 2.0.
Upvotes: 1
Views: 347
Reputation: 185801
No, you cannot synthesize at runtime. That's what you're asking for - runtime code that introspects the properties and generates getters/setters. However @synthesize is a compile-time feature, and must be present in the code at compile time in order to work.
Upvotes: 2