Last active
September 16, 2015 04:04
-
-
Save B0bcat/4bbecf8bf32faeb98011 to your computer and use it in GitHub Desktop.
Schwifty
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 FileWriter { | |
func writeDocument(text: String?, completion((Bool, NSError?) -> Void)?) -> NSError? { | |
var error: NSError? | |
if let cText = text { | |
dispatch_async(myQueue) {() -> Void in | |
let error = writeAndSaveFile(cText) | |
completion?((error == nil), error) | |
} | |
} else { | |
error = NSError.dataEmptyError() | |
} | |
return error | |
} | |
} | |
class Foo { | |
func userDidTypeText(text: String?) { | |
if let error = FileWriter().writeDocument(text) {(success, writeError) in | |
// Stop loading indicator | |
// Show alert with writeError | |
} { | |
// Show alert with error | |
} else { | |
// Start loading indicator | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment