Skip to content

Instantly share code, notes, and snippets.

@maxcampolo
Last active July 22, 2016 14:36
Show Gist options
  • Save maxcampolo/032beb998a7eace9b554b3927bc3f956 to your computer and use it in GitHub Desktop.
Save maxcampolo/032beb998a7eace9b554b3927bc3f956 to your computer and use it in GitHub Desktop.
Just some notes about the intricacies of the swift language.
// 1.) Swift selectors must have @objc if they are not exposed to objective-c (i.e. they are private to a swift class)
// 2.) Make a failable initializer by adding an optional (?) after initializer (init?())
// 3.) To cast in a for in loop use "case". Use "where" to unwrap optionals or check a condition.
for case let button as AClass in view.subviews {
}
for view in childViews where view is UIButton {
}
for case let view as MyCustomView in self.view.subviews {
view.removeFromSuperview
}
for number in numbers where nubmer % 2 = 1 {
}
for optional in optionals where nubmer {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment