官术网_书友最值得收藏!

Using error handling

In any iOS project, a lot of operations may fail and you have to respond to these errors in your project. Since Swift 2, a new mechanism has been added to the language for responding and dealing with errors in your project. You can now throw and catch errors when you do any operation that may fail for some reason. Suppose, you do some logic to request some data in a JSON format from a remote server and then you save this data in a local database. Can you imagine how many errors may happen for these operations? Connection may fail between your app and the remote server, failing to parse the JSON response, database connection is closed, database file doesn't exist, or another process is writing in database and you have to wait. Recovering from these errors allows you take the appropriate action based on the error type.

主站蜘蛛池模板: 云林县| 砀山县| 遂川县| 顺平县| 枣阳市| 开原市| 新和县| 越西县| 前郭尔| 永嘉县| 济源市| 洛浦县| 句容市| 宁德市| 诸暨市| 新和县| 前郭尔| 屏南县| 河东区| 四子王旗| 桐乡市| 华坪县| 乌恰县| 迁安市| 蓝田县| 伽师县| 葵青区| 台南县| 东方市| 胶南市| 平潭县| 桐乡市| 滦平县| 太仆寺旗| 布尔津县| 沙湾县| 江油市| 普宁市| 扬中市| 龙泉市| 固阳县|