>>42 SwiftからLibcを使った例

puts("Hello from libc")
let fd = open("/tmp/scratch.txt", O_WRONLY|O_CREAT, 0o666)

if fd < 0 {
perror("could not open /tmp/scratch.txt")
} else {
let text = "Hello World"
write(fd, text, strlen(text))
close(fd)
}

SwiftからObjective-C の UIColorを使う例

let myTextField = UITextField(frame: CGRect(x: 0.0, y: 0.0, width: 200.0, height: 40.0))

let color = UIColor(red: 0.5, green: 0.0, blue: 0.5, alpha: 1.0)
myTextField.textColor = UIColor.darkGrayColor()
myTextField.text = "Hello world"