Skip to content

Instantly share code, notes, and snippets.

@jeggy
Last active May 11, 2016 17:43
Show Gist options
  • Save jeggy/26e0b099d5e5bb6ee0eefd0988af13e2 to your computer and use it in GitHub Desktop.
Save jeggy/26e0b099d5e5bb6ee0eefd0988af13e2 to your computer and use it in GitHub Desktop.
Idea for removing Todo function
//: 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