使用 CoreData 和 Restful JSON 端点的编程测试

天气报告(编程测试)

要构建完整的项目,请随时查看“功能/持久性”分支

花费的时间

我在周一早上开始了这个项目,花了大约 16 个小时编码

设计选择

考虑到我正在申请高级职位,我决定采用更复杂、更耗时的解决方案。

我没有通过将数据存储为 JSON 来快速构建一些东西,而是采用了 CoreData 解决方案(诚然我有点陌生)。

此外,我使用适当的访问控制(公共,内部私有)构建了“天气服务”文件夹,就好像它是一个单独的库一样。对于这么小的项目来说,异步服务类可能有点矫枉过正,但它绝对是我想要的更大的代码库。

对于一个更大的项目,我也会以这样一种方式完成网络,以抽象出Alamofire(网络代码也会放在一个单独的库中)。

参考资料和第三方库

对于额外的库,我只通过Xcode内置的包管理器添加了Alamofire。

以下是我在从事该项目时查阅的参考资料的简要列表:

https://medium.com/ios-os-x-development/10-core-principles-to-use-coredata-without-blowing-your-head-off-5ed11c623c6b

https://developer.apple.com/documentation/coredata/modeling_data/configuring_entities

https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html

https://stackoverflow.com/questions/57744812/how-to-trigger-uicontextmenuinteraction-context-menu-programmatically

已知问题

我想强调的几个问题:

  1. 错误消息不特定于错误类型

  2. 我没有做过本地化,用较小的屏幕进行测试,可访问性等......

  3. 为了节省时间,我决定不使用/显示云信息(以及其他一些数据点)

关闭

This was a super fun test to knock out; I greatly enjoyed looking at the raw data from various airports I frequent (KORL, KRQB).

I also wanted to say that the JSON object returned from the endpoint seemed really well designed, so I wanted to give a shout out to whoever had a hand in that.

PS. While running the project, I recommend trying the Swipe to delete feature on the list of Airports.

GitHub

点击跳转