I know that a view can only be a subview of one superview, so is it possible to duplicate the UILabel so I don't have to copy the set-up code or write a function to create it?
views:
147answers:
3
A:
The copy method is available by anything that inherits from NSObject so my first port of call would just be to try
UILabel *second = [first copy];
However, this might not work 100% as expected, some UILabel propertiesmight not get copied how you want. If not, you could try using NSCoding methods - encode the object and then decode it into a new object?
It might just be easier to do it by hand though ;)
Sam
deanWombourne
2010-03-28 08:47:28
A:
As said by @starkhalo, UILabel does not conform to NSCopying. so you can not use copy method with UILabel.
Iphone docs for NSObject clearly says -
NSObject does not itself support the NSCopying protocol. Subclasses must support the protocol and implement the copyWithZone: method.
saurabh
2010-04-19 14:10:47