iOS Marvel API:如何获取所有角色 [英] iOS Marvel API: How to get all Characters

查看:39
本文介绍了iOS Marvel API:如何获取所有角色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

晚上,我正在编写一个简单的 Objective-C 应用程序作为学校项目的请求.

Evening, I'm Coding a simple Objective-C app as a request for a school Project.

我必须使用 Marvel API 来检索所有 Marvel Characters,全部.

I have to use the Marvel API to retrieve all the Marvel Characters, ALL of them.

但是在获取字符的 API 中有一种限制,一开始我认为字符列表有不同的页面,但我找不到任何参考.比我看到一个名为limit的查询参数:Limit the result set to the specified number of resources.

But there is a kind of limit in the API getting the characters, in the beginning I was thinking that there were different pages for the characters list, but than I couldn't find any reference to it. Than I saw a query parameter named limit: Limit the result set to the specified number of resources.

所以我决定尝试将限制参数设置为他的最大值 100,它有效,它得到 100 个字符.但是总共有1000个字符.

So I've decided to try with the limit parameter set at his max, 100, and it works, it gets 100 characters. But the characters in total are like 1000.

如果没有设置参数限制,我会得到 20 个字符.

Without setting the parameter limit I get like 20 characters.

这是我迄今为止完成的代码.我正在使用 AFNetworking 吊舱.Github 链接

Here is the code I've done so far. I'm Using AFNetworking pod. Github link

这里是 API 文档

请帮我弄清楚从 Marvel API 请求所有 1000 多个字符的逻辑.

Please help me to figure it with is the logic to request all the 1000+ characters from the marvel API.

推荐答案

听起来您需要实施的技巧是实际触发 几个 HTTP 请求,其中 offset 参数根据先前请求中请求的 limit 递增.

Sounds like the trick that you'll need to implement is to actually trigger several HTTP requests where the offset parameter is incremented based on the limit requested in the prior requests.

它看起来像这样:

  • 请求 1:偏移 0,限制 100
  • 请求 2:偏移 100,限制 100
  • 请求 3:偏移 200,限制 100
  • 请求 4:偏移 300,限制 100
  • 请求 5:偏移 400,限制 100
  • 请求 6:偏移 500,限制 100
  • 请求 7:偏移 600,限制 100
  • 请求 8:偏移 700,限制 100
  • 请求 9:偏移 800,限制 100
  • 请求 10:偏移 900,限制 100

这篇关于iOS Marvel API:如何获取所有角色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆