问题
How would you use Obj-c to search the Apple App store to do the following...
- Return the details of the top 100 in the games overall category or a specific games category
- Return the details of a specific games in the games category
Anyone?
回答1:
Well, as far as I know you have two methods to search the App Store:
- Search API;
- RSS feed generator.
There are many differences between those but the most relevant for your example is that with the Search API you cannot sort the results as they come sorted by relevance and it requires always a search term. The RSS feed generator already has Top Free, Top Paid and Top Grossing categories for you.
Given this I'm going to start answering your question for the RSS feed generator.
- You use the RSS feed generator to generate feeds like this for the top 100 free games in the US store: https://itunes.apple.com/us/rss/topfreeapplications/limit=100/genre=6014/xml;
- Take a loot at this link to get games sub genres;
- You use NSXMLParser library to parse the RSS which already includes the app details.
- You may use the
initWithContentsOfUrl:
method of NSXMLParser; - A quick how-to for this part can be found here.
- You may use the
You can also use StoreKit to get the details of the apps by their ID or show a modal view controller with a specific app but that will require an extra network request.
For the sake of completeness I'll also cover how you can use the Search API.
- Use the Search API to create a URL that describes your search:
- A URL like this allow you to search for apps with that matches "angry birds" - https://itunes.apple.com/search?term=angry+birds&media=software.
- Process the results using NSJSONSerialization library. That already includes the app details.
- Take a loot at this tutorial on how to use the NSJSONSerialization library.
In the end, as @Numan said, this two methods accomplish different things. You said you wanted to have the top 100 games from a specific category and also said you needed to search for a specific game.
You can use my descriptions to create one class that interacts with the App Store in these two ways and return an object defined by you that describes an app (or an array of objects).
回答2:
You can access this info by RSS, look here http://www.apple.com/rss/
Also you can generate RSS feed http://itunes.apple.com/rss/generator/
来源:https://stackoverflow.com/questions/13833521/search-apple-app-store-by-genre-with-ios-obj-c