Skip to content

Instantly share code, notes, and snippets.

@curtisforrester
Created May 11, 2016 15:49
Show Gist options
  • Save curtisforrester/39aebcf2d5c09b14b5b2bf4d033a1183 to your computer and use it in GitHub Desktop.
Save curtisforrester/39aebcf2d5c09b14b5b2bf4d033a1183 to your computer and use it in GitHub Desktop.
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "tag_table" {
let controller = segue.destinationViewController as! BudgetTagsTableViewController
//-- Pass in what we have as the selected tags
controller.selectedTagIDs = self.selectedTagIDs
//-- Closure to receive the selection list and create our tags_string
controller.onCloseSelectedTags = { [unowned self] tags in
self.selectedTagIDs = Set( tags.map { (tag) -> Int in tag.id } )
if self.selectedTagIDs.count > 0 {
let tag_strings = tags.map { (tag) -> String in
return tag.name
}
self.tags_string.next(tag_strings.joinWithSeparator(", "))
}
else {
self.tags_string.next("(None)")
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment