Last active
September 14, 2017 13:52
-
-
Save mwrites/f84c67c8e68946cd3f793bdf393f3a1e to your computer and use it in GitHub Desktop.
JobQueueCenter Dummy upload service
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
class DocumentUploadService : NSObject { | |
var document: Data | |
init(document: Data) { | |
self.document = document | |
super.init() | |
} | |
func execute(complete: @escaping (Bool)->Void) { | |
//do something with the document argument | |
print(document) | |
//our long fake networking method | |
DispatchQueue(label: "networking").asyncAfter(deadline: .now() + 5) { | |
DispatchQueue.main.async { | |
//let's say it only succeed after the second time to simulate unstable network | |
if self.retryableCount == 1 { | |
complete(true) | |
} else { | |
complete(false) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment