swift - How to deal with uncaught exception swift - How to deal with uncaught exception swift swift

swift - How to deal with uncaught exception


If you are looking to handle out of index exception then you can always verify the index item

extension Collection {    /// Returns the element at the specified index if it is within bounds, otherwise nil.    public subscript (safe index: Index) -> Element? {      return indices.contains(index) ? self[index] : nil    }}


There has already been an exhaustively answered similar question Error-Handling in Swift-Language. Look at the first answer there which includes the latest updates in Swift 2.0 regarding this topic.