Skip to content

Instantly share code, notes, and snippets.

@michaelaguiar
Created June 7, 2016 00:08
Embed
What would you like to do?
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