Rename a file


I have a file and want to rename it.


// 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)")

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)