Sometimes copy
is not implemented in some classes like in UILabel
. A workaround would be to create another object and populate it with the attribute values of the original object.
For C# I found the MiscUtil library from Jon Skeet an Marc Gravell which provides a class called PropertyCopy
.
Is there an equivalent (elegant) way to copy values of instancevariables in Objective-C?
At the moment I am doing it manually
myobject.attr1 = otherOBject.attr1;
myobject.attr2 = otherOBject.attr2;
...
but this is tedious and error prone.