Skip to content

Commit 50acb41

Browse files
committed
Rename NSCopying method to swift-3 naming guidelines
1 parent 0c42955 commit 50acb41

40 files changed

+117
-117
lines changed

Diff for: Foundation/NSAffineTransform.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ public class NSAffineTransform : NSObject, NSCopying, NSSecureCoding {
3636
public func encodeWithCoder(_ aCoder: NSCoder) {
3737
NSUnimplemented()
3838
}
39-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
39+
public func copy(with zone: NSZone? = nil) -> AnyObject {
4040
return NSAffineTransform(transform: self)
4141
}
4242
// Necessary because `NSObject.copy()` returns `self`.
4343
public override func copy() -> AnyObject {
44-
return copyWithZone(nil)
44+
return copy(with: nil)
4545
}
4646
public required init?(coder aDecoder: NSCoder) {
4747
NSUnimplemented()

Diff for: Foundation/NSArray.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
112112
}
113113

114114
public override func copy() -> AnyObject {
115-
return copyWithZone(nil)
115+
return copy(with: nil)
116116
}
117117

118-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
118+
public func copy(with zone: NSZone? = nil) -> AnyObject {
119119
if self.dynamicType === NSArray.self {
120120
// return self for immutable type
121121
return self
@@ -128,10 +128,10 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
128128
}
129129

130130
public override func mutableCopy() -> AnyObject {
131-
return mutableCopyWithZone(nil)
131+
return mutableCopy(with: nil)
132132
}
133133

134-
public func mutableCopyWithZone(_ zone: NSZone) -> AnyObject {
134+
public func mutableCopy(with zone: NSZone? = nil) -> AnyObject {
135135
if self.dynamicType === NSArray.self || self.dynamicType === NSMutableArray.self {
136136
// always create and return an NSMutableArray
137137
let mutableArray = NSMutableArray()

Diff for: Foundation/NSAttributedString.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ public class NSAttributedString : NSObject, NSCopying, NSMutableCopying, NSSecur
2828
}
2929

3030
public override func copy() -> AnyObject {
31-
return copyWithZone(nil)
31+
return copy(with: nil)
3232
}
3333

34-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
34+
public func copy(with zone: NSZone? = nil) -> AnyObject {
3535
NSUnimplemented()
3636
}
3737

3838
public override func mutableCopy() -> AnyObject {
39-
return mutableCopyWithZone(nil)
39+
return mutableCopy(with: nil)
4040
}
4141

42-
public func mutableCopyWithZone(_ zone: NSZone) -> AnyObject {
42+
public func mutableCopy(with zone: NSZone? = nil) -> AnyObject {
4343
NSUnimplemented()
4444
}
4545

Diff for: Foundation/NSCFString.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ internal func _CFSwiftStringCreateWithSubstring(_ str: AnyObject, range: CFRange
170170

171171

172172
internal func _CFSwiftStringCreateCopy(_ str: AnyObject) -> Unmanaged<AnyObject> {
173-
return Unmanaged<AnyObject>.passRetained((str as! NSString).copyWithZone(nil))
173+
return Unmanaged<AnyObject>.passRetained((str as! NSString).copy(with: nil))
174174
}
175175

176176
internal func _CFSwiftStringCreateMutableCopy(_ str: AnyObject) -> Unmanaged<AnyObject> {
177-
return Unmanaged<AnyObject>.passRetained((str as! NSString).mutableCopyWithZone(nil))
177+
return Unmanaged<AnyObject>.passRetained((str as! NSString).mutableCopy(with: nil))
178178
}
179179

180180
internal func _CFSwiftStringFastCStringContents(_ str: AnyObject) -> UnsafePointer<Int8>? {

Diff for: Foundation/NSCalendar.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ public class NSCalendar : NSObject, NSCopying, NSSecureCoding {
159159
}
160160

161161
public override func copy() -> AnyObject {
162-
return copyWithZone(nil)
162+
return copy(with: nil)
163163
}
164164

165-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
165+
public func copy(with zone: NSZone? = nil) -> AnyObject {
166166
NSUnimplemented()
167167
}
168168

@@ -1286,10 +1286,10 @@ public class NSDateComponents : NSObject, NSCopying, NSSecureCoding {
12861286
}
12871287

12881288
public override func copy() -> AnyObject {
1289-
return copyWithZone(nil)
1289+
return copy(with: nil)
12901290
}
12911291

1292-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
1292+
public func copy(with zone: NSZone? = nil) -> AnyObject {
12931293
NSUnimplemented()
12941294
}
12951295

Diff for: Foundation/NSCharacterSet.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,18 @@ public class NSCharacterSet : NSObject, NSCopying, NSMutableCopying, NSCoding {
177177
}
178178

179179
public override func copy() -> AnyObject {
180-
return copyWithZone(nil)
180+
return copy(with: nil)
181181
}
182182

183-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
183+
public func copy(with zone: NSZone? = nil) -> AnyObject {
184184
return CFCharacterSetCreateCopy(kCFAllocatorSystemDefault, self._cfObject)
185185
}
186186

187187
public override func mutableCopy() -> AnyObject {
188-
return mutableCopyWithZone(nil)
188+
return mutableCopy(with: nil)
189189
}
190190

191-
public func mutableCopyWithZone(_ zone: NSZone) -> AnyObject {
191+
public func mutableCopy(with zone: NSZone? = nil) -> AnyObject {
192192
return CFCharacterSetCreateMutableCopy(kCFAllocatorSystemDefault, _cfObject)._nsObject
193193
}
194194

Diff for: Foundation/NSData.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,18 @@ public class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
139139
}
140140

141141
public override func copy() -> AnyObject {
142-
return copyWithZone(nil)
142+
return copy(with: nil)
143143
}
144144

145-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
145+
public func copy(with zone: NSZone? = nil) -> AnyObject {
146146
return self
147147
}
148148

149149
public override func mutableCopy() -> AnyObject {
150-
return mutableCopyWithZone(nil)
150+
return mutableCopy(with: nil)
151151
}
152152

153-
public func mutableCopyWithZone(_ zone: NSZone) -> AnyObject {
153+
public func mutableCopy(with zone: NSZone? = nil) -> AnyObject {
154154
return NSMutableData(bytes: UnsafeMutablePointer<Void>(bytes), length: length, copy: true, deallocator: nil)
155155
}
156156

@@ -388,7 +388,7 @@ extension NSData {
388388
return NSData()
389389
}
390390
if range.location == 0 && range.length == self.length {
391-
return copyWithZone(nil) as! NSData
391+
return copy(with: nil) as! NSData
392392
}
393393
return NSData(bytes: bytes.advanced(by: range.location), length: range.length)
394394
}
@@ -605,7 +605,7 @@ public class NSMutableData : NSData {
605605
}
606606
}
607607

608-
public override func copyWithZone(_ zone: NSZone) -> AnyObject {
608+
public override func copy(with zone: NSZone? = nil) -> AnyObject {
609609
return NSData(data: self)
610610
}
611611
}

Diff for: Foundation/NSDate.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ public class NSDate : NSObject, NSCopying, NSSecureCoding, NSCoding {
7979
}
8080

8181
public override func copy() -> AnyObject {
82-
return copyWithZone(nil)
82+
return copy(with: nil)
8383
}
8484

85-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
85+
public func copy(with zone: NSZone? = nil) -> AnyObject {
8686
return self
8787
}
8888

Diff for: Foundation/NSDictionary.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ public class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCodin
175175
}
176176

177177
public override func copy() -> AnyObject {
178-
return copyWithZone(nil)
178+
return copy(with: nil)
179179
}
180180

181-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
181+
public func copy(with zone: NSZone? = nil) -> AnyObject {
182182
if self.dynamicType === NSDictionary.self {
183183
// return self for immutable type
184184
return self
@@ -191,10 +191,10 @@ public class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCodin
191191
}
192192

193193
public override func mutableCopy() -> AnyObject {
194-
return mutableCopyWithZone(nil)
194+
return mutableCopy(with: nil)
195195
}
196196

197-
public func mutableCopyWithZone(_ zone: NSZone) -> AnyObject {
197+
public func mutableCopy(with zone: NSZone? = nil) -> AnyObject {
198198
if self.dynamicType === NSDictionary.self || self.dynamicType === NSMutableDictionary.self {
199199
// always create and return an NSMutableDictionary
200200
let mutableDictionary = NSMutableDictionary()

Diff for: Foundation/NSError.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ public class NSError : NSObject, NSCopying, NSSecureCoding, NSCoding {
102102
}
103103

104104
public override func copy() -> AnyObject {
105-
return copyWithZone(nil)
105+
return copy(with: nil)
106106
}
107107

108-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
108+
public func copy(with zone: NSZone? = nil) -> AnyObject {
109109
return self
110110
}
111111

Diff for: Foundation/NSExpression.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ public class NSExpression : NSObject, NSSecureCoding, NSCopying {
4242
}
4343

4444
public override func copy() -> AnyObject {
45-
return copyWithZone(nil)
45+
return copy(with: nil)
4646
}
4747

48-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
48+
public func copy(with zone: NSZone? = nil) -> AnyObject {
4949
NSUnimplemented()
5050
}
5151

Diff for: Foundation/NSFormatter.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ public class NSFormatter : NSObject, NSCopying, NSCoding {
5757
}
5858

5959
public override func copy() -> AnyObject {
60-
return copyWithZone(nil)
60+
return copy(with: nil)
6161
}
6262

63-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
63+
public func copy(with zone: NSZone? = nil) -> AnyObject {
6464
return self
6565
}
6666

Diff for: Foundation/NSIndexPath.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public class NSIndexPath : NSObject, NSCopying, NSSecureCoding {
2323
}
2424

2525
public override func copy() -> AnyObject {
26-
return copyWithZone(nil)
26+
return copy(with: nil)
2727
}
2828

29-
public func copyWithZone(_ zone: NSZone) -> AnyObject { NSUnimplemented() }
29+
public func copy(with zone: NSZone? = nil) -> AnyObject { NSUnimplemented() }
3030
public convenience init(index: Int) {
3131
self.init(indexes: [index])
3232
}

Diff for: Foundation/NSIndexSet.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ public class NSIndexSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding
4848
}
4949

5050
public override func copy() -> AnyObject {
51-
return copyWithZone(nil)
51+
return copy(with: nil)
5252
}
5353

54-
public func copyWithZone(_ zone: NSZone) -> AnyObject { NSUnimplemented() }
54+
public func copy(with zone: NSZone? = nil) -> AnyObject { NSUnimplemented() }
5555

5656
public override func mutableCopy() -> AnyObject {
57-
return mutableCopyWithZone(nil)
57+
return mutableCopy(with: nil)
5858
}
5959

60-
public func mutableCopyWithZone(_ zone: NSZone) -> AnyObject { NSUnimplemented() }
60+
public func mutableCopy(with zone: NSZone? = nil) -> AnyObject { NSUnimplemented() }
6161
public static func supportsSecureCoding() -> Bool { return true }
6262
public required init?(coder aDecoder: NSCoder) { NSUnimplemented() }
6363
public func encodeWithCoder(_ aCoder: NSCoder) {

Diff for: Foundation/NSKeyedCoderOldStyleArray.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ internal final class _NSKeyedCoderOldStyleArray : NSObject, NSCopying, NSSecureC
9999
}
100100

101101
override func copy() -> AnyObject {
102-
return copyWithZone(nil)
102+
return copy(with: nil)
103103
}
104104

105-
func copyWithZone(_ zone: NSZone) -> AnyObject {
105+
func copy(with zone: NSZone? = nil) -> AnyObject {
106106
return self
107107
}
108108
}

Diff for: Foundation/NSLocale.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ public class NSLocale : NSObject, NSCopying, NSSecureCoding {
5252
}
5353

5454
public override func copy() -> AnyObject {
55-
return copyWithZone(nil)
55+
return copy(with: nil)
5656
}
5757

58-
public func copyWithZone(_ zone: NSZone) -> AnyObject { NSUnimplemented() }
58+
public func copy(with zone: NSZone? = nil) -> AnyObject { NSUnimplemented() }
5959

6060
public func encodeWithCoder(_ aCoder: NSCoder) {
6161
if aCoder.allowsKeyedCoding {

Diff for: Foundation/NSNotification.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public class NSNotification : NSObject, NSCopying, NSCoding {
5656
}
5757

5858
public override func copy() -> AnyObject {
59-
return copyWithZone(nil)
59+
return copy(with: nil)
6060
}
6161

62-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
62+
public func copy(with zone: NSZone? = nil) -> AnyObject {
6363
return self
6464
}
6565

Diff for: Foundation/NSNull.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
public class NSNull : NSObject, NSCopying, NSSecureCoding {
1212

1313
public override func copy() -> AnyObject {
14-
return copyWithZone(nil)
14+
return copy(with: nil)
1515
}
1616

17-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
17+
public func copy(with zone: NSZone? = nil) -> AnyObject {
1818
return self
1919
}
2020

Diff for: Foundation/NSObject.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,23 @@ public struct NSZone : NilLiteralConvertible {
4242

4343
public protocol NSCopying {
4444

45-
func copyWithZone(_ zone: NSZone) -> AnyObject
45+
func copy(with zone: NSZone?) -> AnyObject
4646
}
4747

4848
extension NSCopying {
4949
public func copy() -> AnyObject {
50-
return copyWithZone(nil)
50+
return copy(with: nil)
5151
}
5252
}
5353

5454
public protocol NSMutableCopying {
5555

56-
func mutableCopyWithZone(_ zone: NSZone) -> AnyObject
56+
func mutableCopy(with zone: NSZone?) -> AnyObject
5757
}
5858

5959
extension NSMutableCopying {
6060
public func mutableCopy() -> AnyObject {
61-
return mutableCopyWithZone(nil)
61+
return mutableCopy(with: nil)
6262
}
6363
}
6464

@@ -71,14 +71,14 @@ public class NSObject : NSObjectProtocol, Equatable, Hashable {
7171

7272
public func copy() -> AnyObject {
7373
if let copyable = self as? NSCopying {
74-
return copyable.copyWithZone(nil)
74+
return copyable.copy(with: nil)
7575
}
7676
return self
7777
}
7878

7979
public func mutableCopy() -> AnyObject {
8080
if let copyable = self as? NSMutableCopying {
81-
return copyable.mutableCopyWithZone(nil)
81+
return copyable.mutableCopy(with: nil)
8282
}
8383
return self
8484
}

Diff for: Foundation/NSOrderedSet.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ public class NSOrderedSet : NSObject, NSCopying, NSMutableCopying, NSSecureCodin
1313
internal var _orderedStorage: [NSObject]
1414

1515
public override func copy() -> AnyObject {
16-
return copyWithZone(nil)
16+
return copy(with: nil)
1717
}
1818

19-
public func copyWithZone(_ zone: NSZone) -> AnyObject {
19+
public func copy(with zone: NSZone? = nil) -> AnyObject {
2020
NSUnimplemented()
2121
}
2222

2323
public override func mutableCopy() -> AnyObject {
24-
return mutableCopyWithZone(nil)
24+
return mutableCopy(with: nil)
2525
}
2626

27-
public func mutableCopyWithZone(_ zone: NSZone) -> AnyObject {
27+
public func mutableCopy(with zone: NSZone? = nil) -> AnyObject {
2828
NSUnimplemented()
2929
}
3030

0 commit comments

Comments
 (0)