What do you call a property installer by name?

I asked the appropriate question, but thought that I would share this with my question. See the code below to call the getter property .

SEL propSelector = NSSelectorFromString(propertyName);
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[target class]instanceMethodSignatureForSelector:propSelector]];
[inv setSelector:propSelector];
[inv setTarget:target];
[inv invoke];
float value;
[inv getReturnValue:&value];

I would like to do the same, but call the SETTER property . I would also like to avoid manually creating the setter name by building a string @"setPropertyName:". Bottom Line - is it possible to use the selector created on this line to call setter ?

SEL propSelector = NSSelectorFromString(propertyName);
+5
source share
2 answers

Use encoding with a key.

those. [someObject setValue: anObjectValue forKey: @"foo"];

+10
source

Having read your other question earlier today, this is what I can come up with:

. , , .

- foo: setFoo:. , ( , )

0

All Articles