Created
April 9, 2015 00:33
-
-
Save mgp/dfe381800ee2cc3fa3e2 to your computer and use it in GitHub Desktop.
Failed use of an anonymous inner class
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
| override func loadView() { | |
| // Create a KAExerciseControlsDelegate implementation that invokes methods on the delegate | |
| // of this instance. | |
| weak var weakSelf = self | |
| class ViewDelegate: KAExerciseControlsDelegate { | |
| // Invokes the given block with the view controller and its delegate, if both are still | |
| // allocated. | |
| private func callControllerDelegate(caller: (ExerciseControlsViewDelegate, ExerciseControlsViewController) -> Void) { | |
| if let strongSelf = weakSelf, strongDelegate = strongSelf.delegate { | |
| caller(strongDelegate, strongSelf) | |
| } | |
| } | |
| @objc func exerciseControlsDidSelectCheckAnswer(controlsContainer: KAExerciseControlsView) { | |
| callControllerDelegate { $0.exerciseControlsViewController($1, didTapProgressButtonActionWithProgressType: .CheckAnswer) } | |
| } | |
| @objc func exerciseControlsDidSelectNextProblem(controlsContainer: KAExerciseControlsView) { | |
| callControllerDelegate { $0.exerciseControlsViewController($1, didTapProgressButtonActionWithProgressType: .NextProblem) } | |
| } | |
| @objc func exerciseControlsDidSelectEndOfTask(controlsContainer: KAExerciseControlsView) { | |
| callControllerDelegate { $0.exerciseControlsViewController($1, didTapProgressButtonActionWithProgressType: .EndOfTask) } | |
| } | |
| @objc func exerciseControlsDidSelectHints(controlsContainer: KAExerciseControlsView) { | |
| callControllerDelegate { $0.exerciseControlsViewControllerDidSelectHints($1) } | |
| } | |
| @objc func exerciseControlsDidSelectRelatedVideos(controlsContainer: KAExerciseControlsView) { | |
| callControllerDelegate { $0.exerciseControlsViewControllerDidSelectRelatedVideos($1) } | |
| } | |
| @objc func exerciseControlsDidSelectSkipProblem(controlsContainer: KAExerciseControlsView) { | |
| callControllerDelegate { $0.exerciseControlsViewControllerDidSelectSkipProblem($1) } | |
| } | |
| } | |
| view = KAExerciseControlsView(delegate: ViewDelegate(), shouldHideSkipProblemButton: shouldHideSkipProblemButton) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment