I understand that dividing by int (0) raises a flag and not an exception in objective-c. What would be the best way to manually throw a custom exception when you test a divisor for (0)?
The exception clearly has to be throw when one is validating the divisor. To be even more specific on the question, is it better to catch the exception on a divide method, or in th开发者_如何学Goe validation of the divisor which is where I think the exception should be thrown?
Where does the division occur? Can you just check if the divisor is zero before performing the arithmetic, and throw the exception there?
I like in Java it will throw an exception. But it seems in objective C you will always have to manually check the denominator.
精彩评论