{"id":23087247,"url":"https://github.com/yuhanle/wsapiinvoker","last_synced_at":"2025-08-16T06:32:35.614Z","repository":{"id":217382923,"uuid":"49471566","full_name":"yuhanle/WSApiInvoker","owner":"yuhanle","description":"封装 AFNetworking 的网络模块","archived":false,"fork":false,"pushed_at":"2016-06-02T08:10:38.000Z","size":476,"stargazers_count":24,"open_issues_count":0,"forks_count":4,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-04T08:03:05.866Z","etag":null,"topics":["afnetworking"],"latest_commit_sha":null,"homepage":"https://latehorse.github.io/","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuhanle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-01-12T03:14:48.000Z","updated_at":"2023-02-17T09:33:25.000Z","dependencies_parsed_at":"2024-01-16T03:39:39.230Z","dependency_job_id":"12860890-7339-4b50-8772-bcbcd9472bf0","html_url":"https://github.com/yuhanle/WSApiInvoker","commit_stats":null,"previous_names":["yuhanle/wsapiinvoker"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yuhanle/WSApiInvoker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuhanle%2FWSApiInvoker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuhanle%2FWSApiInvoker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuhanle%2FWSApiInvoker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuhanle%2FWSApiInvoker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuhanle","download_url":"https://codeload.github.com/yuhanle/WSApiInvoker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuhanle%2FWSApiInvoker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270677694,"owners_count":24626814,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["afnetworking"],"created_at":"2024-12-16T19:55:40.417Z","updated_at":"2025-08-16T06:32:35.280Z","avatar_url":"https://github.com/yuhanle.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WSApiInvoker\n一个封装AFNetworking的网络请求Demo\n\n## 简介\n- AFWSApiInvoker\n\n  主要负责调用AFN做网络请求以及返回错误信息和请求结果\n  \n- ApiInvoker\n\n  所有api请求类的父类，用于填充请求相关信息以及统一接口\n  \n- ApiRequest\n\n  网络请求实例\n  包含请求的所有信息\n  \n- ApiResponse\n  \n  服务器回应实例\n  \n- WSApi\n  \n  单例 \n  继成ApiInvoker，负责提供请求相关接口\n  \n- WSDevApi\n\n  分类api，继承WSApi，负责提供分类里的请求接口\n\n## 目录文件\n\n![](https://github.com/yuhanle/WSApiInvoker/blob/master/Screen.png)\n\n## 其他探讨\n\n\u003e 1. 交付什么样的数据给业务层？\n\n我见过非常多的App的网络层在拿到JSON数据之后，会将数据转变成对应的对象原型。注意，我这里指的不是NSDictionary，而是类似Item这样的对象。这种做法是能够提高后续操作代码的可读性的。在比较直觉的思路里面，是需要这部分转化过程的，但这部分转化过程的成本是很大的，主要成本在于：\n\n```\n1.数组内容的转化成本较高：数组里面每项都要转化成Item对象，如果Item对象中还有类似数组，就很头疼。\n2.转化之后的数据在大部分情况是不能直接被展示的，为了能够被展示，还需要第二次转化。\n3.只有在API返回的数据高度标准化时，这些对象原型（Item）的可复用程度才高，否则容易出现类型爆炸，提高维护成本。\n4.调试时通过对象原型查看数据内容不如直接通过NSDictionary/NSArray直观。\n5.同一API的数据被不同View展示时，难以控制数据转化的代码，它们有可能会散落在任何需要的地方。\n```\n\n其实我们的理想情况是希望API的数据下发之后就能够直接被View所展示。首先要说的是，这种情况非常少。另外，这种做法使得View和API联系紧密，也是我们不希望发生的。\n\n有问题，欢迎提issue，或者微博探讨\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuhanle%2Fwsapiinvoker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuhanle%2Fwsapiinvoker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuhanle%2Fwsapiinvoker/lists"}