Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save biku/480226a9cf4bbd666975544e4a68c156 to your computer and use it in GitHub Desktop.

Select an option

Save biku/480226a9cf4bbd666975544e4a68c156 to your computer and use it in GitHub Desktop.
class Ns:NSObject {
var title: String = "unset"
}
struct Me {
var me:[Ns] {
didSet {
print("set me")
}
}
}
let one = Ns()
let two = Ns()
var m = Me(me:[one, two])
m.me.first?.title
m.me.last?.title
if var firstNs = m.me.first, let indexOfOne = m.me.indexOf(firstNs) {
firstNs.title = "first"
m.me[indexOfOne] = firstNs // this will force a didSet
}
m.me.first?.title
m.me.last?.title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment