Skip to content

Commit 5d272d2

Browse files
jpsimparkera
authored andcommitted
update NSUUID.UUIDString to uuidString to match Darwin version (#483)
as of Xcode 8
1 parent 53da67a commit 5d272d2

File tree

8 files changed

+28
-28
lines changed

8 files changed

+28
-28
lines changed

Foundation/NSUUID.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class NSUUID : NSObject, NSCopying, NSSecureCoding, NSCoding {
2323
_cf_uuid_generate_random(buffer)
2424
}
2525

26-
public convenience init?(UUIDString string: String) {
26+
public convenience init?(uuidString string: String) {
2727
let buffer = UnsafeMutablePointer<UInt8>.allocate(capacity: 16)
2828
if _cf_uuid_parse(string, buffer) != 0 {
2929
return nil
@@ -39,7 +39,7 @@ public class NSUUID : NSObject, NSCopying, NSSecureCoding, NSCoding {
3939
_cf_uuid_copy(uuid, buffer)
4040
}
4141

42-
public var UUIDString: String {
42+
public var uuidString: String {
4343
let strPtr = UnsafeMutablePointer<Int8>.allocate(capacity: 37)
4444
_cf_uuid_unparse_upper(buffer, strPtr)
4545
return String(cString: strPtr)
@@ -97,6 +97,6 @@ public class NSUUID : NSObject, NSCopying, NSSecureCoding, NSCoding {
9797
}
9898

9999
public override var description: String {
100-
return UUIDString
100+
return uuidString
101101
}
102102
}

TestFoundation/TestNSBundle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class TestNSBundle : XCTestCase {
108108

109109
private func _setupPlayground() -> String? {
110110
// Make sure the directory is uniquely named
111-
let tempDir = "/tmp/TestFoundation_Playground_" + NSUUID().UUIDString + "/"
111+
let tempDir = "/tmp/TestFoundation_Playground_" + NSUUID().uuidString + "/"
112112

113113
do {
114114
try FileManager.default().createDirectory(atPath: tempDir, withIntermediateDirectories: false, attributes: nil)

TestFoundation/TestNSFileManager.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class TestNSFileManager : XCTestCase {
3838

3939
func test_createDirectory() {
4040
let fm = FileManager.default()
41-
let path = "/tmp/testdir\(NSUUID().UUIDString)"
41+
let path = "/tmp/testdir\(NSUUID().uuidString)"
4242

4343
ignoreError { try fm.removeItem(atPath: path) }
4444

@@ -63,7 +63,7 @@ class TestNSFileManager : XCTestCase {
6363

6464
func test_createFile() {
6565
let fm = FileManager.default()
66-
let path = "/tmp/testfile\(NSUUID().UUIDString)"
66+
let path = "/tmp/testfile\(NSUUID().uuidString)"
6767

6868
ignoreError { try fm.removeItem(atPath: path) }
6969

@@ -83,8 +83,8 @@ class TestNSFileManager : XCTestCase {
8383

8484
func test_moveFile() {
8585
let fm = FileManager.default()
86-
let path = "/tmp/testfile\(NSUUID().UUIDString)"
87-
let path2 = "/tmp/testfile2\(NSUUID().UUIDString)"
86+
let path = "/tmp/testfile\(NSUUID().uuidString)"
87+
let path2 = "/tmp/testfile2\(NSUUID().uuidString)"
8888

8989
func cleanup() {
9090
ignoreError { try fm.removeItem(atPath: path) }
@@ -114,7 +114,7 @@ class TestNSFileManager : XCTestCase {
114114

115115
func test_fileAttributes() {
116116
let fm = FileManager.default()
117-
let path = "/tmp/test_fileAttributes\(NSUUID().UUIDString)"
117+
let path = "/tmp/test_fileAttributes\(NSUUID().uuidString)"
118118

119119
ignoreError { try fm.removeItem(atPath: path) }
120120

@@ -161,7 +161,7 @@ class TestNSFileManager : XCTestCase {
161161
}
162162

163163
func test_setFileAttributes() {
164-
let path = "/tmp/test_setFileAttributes\(NSUUID().UUIDString)"
164+
let path = "/tmp/test_setFileAttributes\(NSUUID().uuidString)"
165165
let fm = FileManager.default()
166166

167167
ignoreError { try fm.removeItem(atPath: path) }
@@ -188,7 +188,7 @@ class TestNSFileManager : XCTestCase {
188188

189189
func test_pathEnumerator() {
190190
let fm = FileManager.default()
191-
let testDirName = "testdir\(NSUUID().UUIDString)"
191+
let testDirName = "testdir\(NSUUID().uuidString)"
192192
let basePath = "/tmp/\(testDirName)"
193193
let itemPath = "/tmp/\(testDirName)/item"
194194
let basePath2 = "/tmp/\(testDirName)/path2"
@@ -221,7 +221,7 @@ class TestNSFileManager : XCTestCase {
221221

222222
func test_directoryEnumerator() {
223223
let fm = FileManager.default()
224-
let testDirName = "testdir\(NSUUID().UUIDString)"
224+
let testDirName = "testdir\(NSUUID().uuidString)"
225225
let path = "/tmp/\(testDirName)"
226226
let itemPath = "/tmp/\(testDirName)/item"
227227

@@ -327,7 +327,7 @@ class TestNSFileManager : XCTestCase {
327327

328328
func test_contentsOfDirectoryAtPath() {
329329
let fm = FileManager.default()
330-
let testDirName = "testdir\(NSUUID().UUIDString)"
330+
let testDirName = "testdir\(NSUUID().uuidString)"
331331
let path = "/tmp/\(testDirName)"
332332
let itemPath1 = "/tmp/\(testDirName)/item"
333333
let itemPath2 = "/tmp/\(testDirName)/item2"

TestFoundation/TestNSJSONSerialization.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ extension TestNSJSONSerialization {
839839
}
840840

841841
private func createTestFile(_ path: String,_contents: Data) -> String? {
842-
let tempDir = "/tmp/TestFoundation_Playground_" + NSUUID().UUIDString + "/"
842+
let tempDir = "/tmp/TestFoundation_Playground_" + NSUUID().uuidString + "/"
843843
do {
844844
try FileManager.default().createDirectory(atPath: tempDir, withIntermediateDirectories: false, attributes: nil)
845845
if FileManager.default().createFile(atPath: tempDir + "/" + path, contents: _contents,

TestFoundation/TestNSKeyedUnarchiver.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class TestNSKeyedUnarchiver : XCTestCase {
5151
}
5252

5353
func test_unarchive_complex() {
54-
let uuid = NSUUID(UUIDString: "71DC068E-3420-45FF-919E-3A267D55EC22")!
54+
let uuid = NSUUID(uuidString: "71DC068E-3420-45FF-919E-3A267D55EC22")!
5555
let url = URL(string: "index.xml", relativeTo: URL(string: "https://www.swift.org"))!
5656
let array = NSArray(array: [ NSNull(), NSString(string: "hello"), NSNumber(value: 34545), ["key" : "val"].bridge() ])
5757
let dict : Dictionary<String, NSObject> = [
@@ -106,7 +106,7 @@ class TestNSKeyedUnarchiver : XCTestCase {
106106
}
107107

108108
func test_unarchive_uuid() {
109-
let uuid = NSUUID(UUIDString: "0AD863BA-7584-40CF-8896-BD87B3280C34")
109+
let uuid = NSUUID(uuidString: "0AD863BA-7584-40CF-8896-BD87B3280C34")
110110
test_unarchive_from_file("NSKeyedUnarchiver-UUIDTest", uuid!)
111111
}
112112
}

TestFoundation/TestNSStream.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class TestNSStream : XCTestCase {
217217
}
218218

219219
private func createTestFile(_ path: String, _contents: Data) -> String? {
220-
let tempDir = "/tmp/TestFoundation_Playground_" + NSUUID().UUIDString + "/"
220+
let tempDir = "/tmp/TestFoundation_Playground_" + NSUUID().uuidString + "/"
221221
do {
222222
try FileManager.default().createDirectory(atPath: tempDir, withIntermediateDirectories: false, attributes: nil)
223223
if FileManager.default().createFile(atPath: tempDir + "/" + path, contents: _contents,

TestFoundation/TestNSString.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ class TestNSString : XCTestCase {
496496
}
497497

498498
do {
499-
let path = tmpPath(NSUUID().UUIDString)
499+
let path = tmpPath(NSUUID().uuidString)
500500
var outName: NSString?
501501
var matches: [NSString] = []
502502
let count = path.completePathIntoString(&outName, caseSensitive: false, matchesIntoArray: &matches, filterTypes: nil)
@@ -802,7 +802,7 @@ class TestNSString : XCTestCase {
802802
}
803803

804804
do {
805-
let userName = NSUUID().UUIDString
805+
let userName = NSUUID().uuidString
806806
let path = NSString(string: "~\(userName)/")
807807
let result = path.stringByExpandingTildeInPath
808808
// next assert fails in VirtualBox because home directory for unknown user resolved to /var/run/vboxadd

TestFoundation/TestNSUUID.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ class TestNSUUID : XCTestCase {
2323
return [
2424
("test_Equality", test_Equality),
2525
("test_InvalidUUID", test_InvalidUUID),
26-
("test_UUIDString", test_UUIDString),
26+
("test_uuidString", test_uuidString),
2727
("test_description", test_description),
2828
// Disabled until NSKeyedArchiver and NSKeyedUnarchiver are implemented
2929
// ("test_NSCoding", test_NSCoding),
3030
]
3131
}
3232

3333
func test_Equality() {
34-
let uuidA = NSUUID(UUIDString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")
35-
let uuidB = NSUUID(UUIDString: "e621e1f8-c36c-495a-93fc-0c247a3e6e5f")
34+
let uuidA = NSUUID(uuidString: "E621E1F8-C36C-495A-93FC-0C247A3E6E5F")
35+
let uuidB = NSUUID(uuidString: "e621e1f8-c36c-495a-93fc-0c247a3e6e5f")
3636
let uuidC = NSUUID(UUIDBytes: [0xe6,0x21,0xe1,0xf8,0xc3,0x6c,0x49,0x5a,0x93,0xfc,0x0c,0x24,0x7a,0x3e,0x6e,0x5f])
3737
let uuidD = NSUUID()
3838

@@ -42,20 +42,20 @@ class TestNSUUID : XCTestCase {
4242
}
4343

4444
func test_InvalidUUID() {
45-
let uuid = NSUUID(UUIDString: "Invalid UUID")
46-
XCTAssertNil(uuid, "The convenience initializer `init?(UUIDString string:)` must return nil for an invalid UUID string.")
45+
let uuid = NSUUID(uuidString: "Invalid UUID")
46+
XCTAssertNil(uuid, "The convenience initializer `init?(uuidString string:)` must return nil for an invalid UUID string.")
4747
}
4848

49-
// `UUIDString` should return an uppercase string
49+
// `uuidString` should return an uppercase string
5050
// See: https://bugs.swift.org/browse/SR-865
51-
func test_UUIDString() {
51+
func test_uuidString() {
5252
let uuid = NSUUID(UUIDBytes: [0xe6,0x21,0xe1,0xf8,0xc3,0x6c,0x49,0x5a,0x93,0xfc,0x0c,0x24,0x7a,0x3e,0x6e,0x5f])
53-
XCTAssertEqual(uuid.UUIDString, "E621E1F8-C36C-495A-93FC-0C247A3E6E5F", "The UUIDString representation must be uppercase.")
53+
XCTAssertEqual(uuid.uuidString, "E621E1F8-C36C-495A-93FC-0C247A3E6E5F", "The uuidString representation must be uppercase.")
5454
}
5555

5656
func test_description() {
5757
let uuid = NSUUID()
58-
XCTAssertEqual(uuid.description, uuid.UUIDString, "The description must be the same as the UUIDString.")
58+
XCTAssertEqual(uuid.description, uuid.uuidString, "The description must be the same as the uuidString.")
5959
}
6060

6161
func test_NSCoding() {

0 commit comments

Comments
 (0)