2

In Objective-C, you can make your class instance copyable by implementing NSCopying and copyWithZone:. How do you do similar thing in Swift (without using Foundation)?

Boon
  • 40,656
  • 60
  • 209
  • 315
  • 1
    Write your own copy method. – Abizern Sep 03 '14 at 00:12
  • But who can you create an instance of the same class as `self`? That is in cases where you implement `copyWithZone:` for different subclasses. I've been trying with `self.dynamicType` with no luck. – Rivera Mar 24 '15 at 17:12
  • Here is an easy way to do it. http://stackoverflow.com/a/35915186/4757335 – Misternewb Mar 12 '16 at 15:40

0 Answers0