I am using a for-loop to iterate an array. When the index is out of bounds, the exception breakpoint is not stopping at the point of error.
My code
class ViewController: UIViewController
{
let integers = [1, 2, 3]
override func viewDidLoad()
{
super.viewDidLoad()
iterate(givenArray: integers)
}
func iterate(givenArray: [Int])
{
for index in 0...givenArray.count
{
print(givenArray[index])
}
}
}
I am getting the following error at the console.
1 2 3 Fatal error: Index out of range 2020-01-06 14:29:09.726533+0530 Playground[93060:2221772] Fatal error: Index out of range
I understand the error. My question is that though I have added the Exception breakpoint, why is it not working?