Last active
May 11, 2016 17:43
-
-
Save jeggy/26e0b099d5e5bb6ee0eefd0988af13e2 to your computer and use it in GitHub Desktop.
Idea for removing Todo function
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
//: Playground - noun: a place where people can play | |
import UIKit | |
func removeTodo(t: String, hasChildren: () -> Bool, ifAcceptedCh: (success: Bool) -> Void){ | |
if t == "Kids"{ | |
if hasChildren() { | |
ifAcceptedCh(success: true) | |
} | |
} else { | |
ifAcceptedCh(success: true) | |
} | |
} | |
let text = "Kids" | |
removeTodo(text, hasChildren: { // hasChildren is only called if it has children. | |
// Have some extra popup check to ask user if they really wanna delete this and all it's children. | |
return false | |
} | |
// This will only be called if | |
// text != "Kids" OR hasChildren returns true | |
, ifAcceptedCh: { | |
success in | |
if success{ | |
print("Successfully deleted") | |
}else{ | |
print("some internet error") | |
} | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment