Created
June 7, 2016 00:08
-
-
Save michaelaguiar/49fbf160df8c493817db2ec5681f746e to your computer and use it in GitHub Desktop.
Rename a file in Swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a FileManager instance | |
let fileManager = NSFileManager.defaultManager() | |
// Rename 'hello.swift' as 'goodbye.swift' | |
do { | |
try fileManager.moveItemAtPath("hello.swift", toPath: "goodbye.swift") | |
} catch let error as NSError { | |
print("Ooops! Something went wrong: \(error)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment