Skip to content

Commit a94f849

Browse files
committed
dynamically dispatch copy and mutableCopy to their zone methods
1 parent 1b878a0 commit a94f849

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Foundation/NSObject.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,16 @@ public class NSObject : NSObjectProtocol {
7272
}
7373

7474
public func copy() -> AnyObject {
75+
if let copyable = self as? NSCopying {
76+
return copyable.copyWithZone(nil)
77+
}
7578
return self
7679
}
7780

7881
public func mutableCopy() -> AnyObject {
82+
if let copyable = self as? NSMutableCopying {
83+
return copyable.mutableCopyWithZone(nil)
84+
}
7985
return self
8086
}
8187

0 commit comments

Comments
 (0)