Skip to content

Instantly share code, notes, and snippets.

@marcpalmer
Created January 5, 2015 11:36
Show Gist options
  • Save marcpalmer/283333cd3ce9032e7637 to your computer and use it in GitHub Desktop.
Save marcpalmer/283333cd3ce9032e7637 to your computer and use it in GitHub Desktop.
Puzzling compiler error with Xcode 6.2 (6C101)
// Works
class Testing {
func something() {
dispatch_async(dispatch_get_main_queue()) {
[weak self] in
if let blockSelf = self {
blockSelf.somethingElse()
}
}
}
func somethingElse() {
}
}
// Works
class TestingAgain {
func something() {
dispatch_async(dispatch_get_main_queue()) {
[weak self] in
self!.somethingElse()
}
}
func somethingElse() {
}
}
/* Fails with:
error: cannot convert the expression's type '(dispatch_queue_t, () -> () -> $T3)' to type '()'
self?.somethingElse()
~~~~~~^~~~~~~~~~~~~~~
*/
class TestingYetAgain {
func something() {
dispatch_async(dispatch_get_main_queue()) {
[weak self] in
self?.somethingElse()
}
}
func somethingElse() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment