Xcode Playground Killer Codes

Xcode Playground Killer Codes in Swift Language (from Xcode 6 Beta 2)

Iteration of AnyObject?
import Cocoa

let fm = NSFileManager.defaultManager()
var error: NSError?
let contents = fm.contentsOfDirectoryAtPath("/foo/bar", error: &error)

for content: String! in contents {
    content
}

Returning Tuple in Extension
import Foundation

extension NSDate {
    var testProperty: (Int, Int, Int) {
        return (0, 0, 0)
    }
}

NSDate.date().testProperty

Sweet! :-p

댓글

이 블로그의 인기 게시물

소수점 제거 함수 삼총사 ceil(), floor(), round()

버전(Version)을 제대로 이해하기