Skip to content

Instantly share code, notes, and snippets.

@michaelaguiar
Created June 7, 2016 00:08
Show Gist options
  • Save michaelaguiar/49fbf160df8c493817db2ec5681f746e to your computer and use it in GitHub Desktop.
Save michaelaguiar/49fbf160df8c493817db2ec5681f746e to your computer and use it in GitHub Desktop.
Rename a file in Swift
// 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