Last active
August 29, 2015 14:25
-
-
Save dealforest/edde2632c644c3dc9d04 to your computer and use it in GitHub Desktop.
only Swfit 1.2
This file contains hidden or 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
let request = GitHub.Endpoint.SearchRepositories(query: "APIKit", sort: .Stars) | |
GitHub.sendRequest(request) | |
.success { println($0) } | |
.failure { println($0) } | |
extension GitHub { | |
func sendRequest<T: APIKit.Request>(request: T) -> Task<Float, T.Response, NSError> { | |
return Task { progress, fulfill, reject, configure in | |
/* | |
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1 | |
を回避するために必要 | |
*/ | |
let fulfill = fulfill | |
let reject = reject | |
GitHub.sendRequest(request) { response in | |
switch response { | |
case .Success(let box): | |
fulfill(box.value) | |
case .Failure(let box): | |
reject(box.value) | |
} | |
} | |
} | |
} | |
} |
// NG
class A {
func a() -> (String -> Void) {
return { value in
{
println(value)
}
}
}
}
// OK
class A {
func a() -> (String -> Void) {
return { value in
let b = {
println(value)
}
}
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
これでもとおった