Saturday, 15 August 2015

ios - unrecognized selector sent to instance @dynamic -


I was doing some research on the difference between dynamic and @ synthesis, so I'm making a small (simple) example:

  @interface clas: NSobax @ property (nanatomic) int value; @end @implementation Classe @ Synthesis value; @ End int main (int argued, cons charch * archive []) {@autoreleasepool {classe * cl = [[class alloc] init]; Cl.value = 50; NSLog (@ "% d", cl.value); } Return 0; }  

What do I understand from my example, is that the 'synthesized' creates behind the scenes of disorder and the setter methods, and just as we have seen above, only cl Now, let's talk about dynamic, I've heard that

is one way to inform the system that do not generate gates / siters to talk about, that you (or any other ) Will provide them for you.

Ok, if I give the error of returning the following message to @ synthesize on the @ dynamic application in the above example:

unrecognized selector sent to instance 0x10010eeb0

it was because it was said that the compiler Getters and not Setters way to learn How can I create Gators and Centers manually?

OK, you just do that if your property name is

 < Code> @property (nonatomic) int value;  

Then you define only the methods in your implementation:

  - (int) value {// your welcome here} - (zero) set Value: (int) NewValue {// Your Sentter Here}  

And you do not need to do @ Dynamic to do this You just have a waiter and a setter However you may need to type code synthesis because if you specify your own recipient and setter Not, then the compiler is an example will not generate variable ( _value ) to do it (if you need it), you @ synthesis will need .

More about this:.


No comments:

Post a Comment