Created
January 5, 2015 11:36
-
-
Save marcpalmer/283333cd3ce9032e7637 to your computer and use it in GitHub Desktop.
Puzzling compiler error with Xcode 6.2 (6C101)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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