Created
May 11, 2016 15:49
-
-
Save curtisforrester/39aebcf2d5c09b14b5b2bf4d033a1183 to your computer and use it in GitHub Desktop.
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
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