small medium large xlarge

Generic-user-small
14 Jul 2016, 12:35
Todd Valentine (2 posts)

The textChangedClosure defined in PPRTextEditViewController throws, but when I look at the initialization of the block in PPREditRecipeViewController::prepareForEditRecipeNameSegue(:) I don’t see it throwing an error.

Could you explain this?

Avatarsmall_pragsmall
14 Jul 2016, 15:12
Marcus S. Zarra (284 posts)

The throw is there so that the closure you pass in can throw to indicate an issue with the text being inputted.

For example, if you look at PPREditRecipeViewController around line 163, you will see where the servings view controller (the same class underneath) is throwing if the text inputted cannot be turned into a string.

The PPRTextEditViewController catches the throw, presents an error and allows the user to correct the error.

The throw is not used in every situation but it is there as an error path in situations where the inputted data needs to be verified.

You must be logged in to comment