Skip to content

Instantly share code, notes, and snippets.

@sferrini
Forked from ignazioc/Binding.swift
Last active July 14, 2017 12:56
Show Gist options
  • Save sferrini/4f1db46183b2cc75438fb597f019cc9a to your computer and use it in GitHub Desktop.
Save sferrini/4f1db46183b2cc75438fb597f019cc9a to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
struct User {
var name: String
init() {
name = ""
}
}
class UserProfile {
var user: User = User() {
didSet {
print("didSet \(user.name)")
}
}
}
let userProfile = UserProfile()
var user = User()
userProfile.user = User()
userProfile.user.name = "First Update"
withUnsafePointer(to: &userProfile.user.name) {
print("name has address: \($0)")
}
userProfile.user.name = "Second Update"
withUnsafePointer(to: &userProfile.user.name) {
print("name has address: \($0)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment