Last active
June 1, 2016 09:24
-
-
Save dangthaison91/30d35699fd4fef69f810c0e8213743b0 to your computer and use it in GitHub Desktop.
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
private var lastScheduledWord: dispatch_cancelable_block_t? | |
private var lastRequest: NSURLSessionTask? | |
func searchRepository(keyword: String) { | |
cancel_block(lastScheduledWord) | |
lastRequest?.cancel() | |
lastRequest = nil | |
lastScheduledWord = dispatch_after_delay(0.5) { | |
lastRequest = findRepository(keyword, success: { repository in | |
findIssues(repository) | |
}, failure: { error in | |
displayError(error) | |
} | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment