YTKNetwork icon indicating copy to clipboard operation
YTKNetwork copied to clipboard

假如一个项目有200多个接口,一个请求接口就是一个类,那不要建200多个类?请问有什么好的解决方案吗?

Open Torin2876 opened this issue 7 years ago • 7 comments

提出问题前请先确认完成了下列几项步骤 New Issue Checklist

  • [ ] 我已经阅读过 贡献指南 I have read and understood the CONTRIBUTING guide
  • [ ] 我已经阅读过 程序文档 I have read the Documentation
  • [ ] 我已经证实这个问题来源于 YTKNetwork 本身,而不是其所依赖的 AFNetworking I have confirmed that this issue is caused by YTKNetwork, not AFNetworking
  • [ ] 我已经在项目的 问题列表 中搜索过并且没有找到类似问题 I have searched for a similar issue in the project and found none

问题描述 Issue Description

请给出所提出问题的详尽描述,包括具体的错误信息,打印的堆栈等等,以及重现此问题的具体步骤。

Please fill in the detailed description of the issue (full output of any stack trace, compiler error, ...) and the steps to reproduce the issue.

Torin2876 avatar Sep 22 '17 02:09 Torin2876

嗯嗯

Torin2876 avatar Sep 22 '17 02:09 Torin2876

@Torin2876 可以查考:https://casatwy.com/iosying-yong-jia-gou-tan-wang-luo-ceng-she-ji-fang-an.html

liangdahong avatar Sep 22 '17 03:09 liangdahong

是的。200个

jacksonon avatar Sep 22 '17 03:09 jacksonon

我觉得有些返回数据结构一样的话可以写在一个类里面,也不是非要一个接口一个类

yangxueya1983 avatar Sep 28 '17 11:09 yangxueya1983

如果说多个不同的接口200个。连续去写200个基于YTKRequest的类。。这对于项目来说比较臃肿。有没有啥好办法。。。

huangdougod avatar Apr 27 '18 02:04 huangdougod

我看的时候就一直在思考这个问题, 原来还真是这样, 项目接口越多越臃肿, 接口越少,又没必要用这个, 好尴尬

huangbingke avatar Jun 11 '18 01:06 huangbingke

封装啊,用AFN怎么封装的这个也一样啊。。。先写个baseRequest类把除baseURL之外的要拼接的那段和parameters作为属性暴露出去,再写个类开启请求调上面的baseRequest

kaitopic avatar Nov 22 '19 06:11 kaitopic