How to parse GTFS data on iOS using swift? - ios

I am using http://datamine.mta.info/list-of-feeds api to get GTFS data for United States transportation.
When you call http://datamine.mta.info/mta_esi.php?key=<key>&feed_id=1 api you get one "gtfs" file which contains data that I need to parse in iOS so that I can display.
Once I get the file, how do I parse it? So far I haven't found a way to do so. Anyone can help me on this?
Thanks,
Pratik

The MTA requires that you serve the realtime data from your own server, so you might as well parse the Protocol Buffers server-side, and then make your data available to your iOS app from your server. If you do it that way, then you can use e.g., a Python or C++ library to parse the PB into JSON or whatever and structure it in an optimal way for your app for download.

Related

GetStream feeds without enrichment

Because of some requirements, we don't want to use the enrichment system where stream gets from its own collection the data objects.
In fact, we want to do it as the backend would do, using our own database, but directly from the client (because we don't use any database)
However, when retrieving the activities, we get the following: (iOS)
JSON decoding error: The data couldn’t be read because it isn’t in the correct format..
We create activities in the way that, actor is User:UserID, Object is Object:PostID, Verb:ActionEnum.
That's all we do.. but one more time, we are facing issues on iOS SDK..
Why?
To anyone having this issue, it was coming from the iOS SDK itself... It turned out that, using the REST API from our client solved the issue, but we had to use the "extra" field part of Go to deliver our required data :)
Hope it helps

How to use Walmart API with iOS app in Xcode? (swift language)

I've recently installed Walmart's API into my iOS app. The app's purpose is for the user to search for items using Walmart's API and then display the queried items to the user. However I am having a hard time finding any examples on how to use Walmart's API with Xcode and Swift language. Was curious if anyone could point me in the direction of how to properly use the API while using Swift language or if anyone has experience using the Walmart API in Xcode? I feel like it shouldn't be hard to accomplish what I am trying to do but right now I am a bit lost. All help and advice is appreciated in advance! Thanks.
Whenever An API is Created The Author gives out a Documentation, about the usage of the API, Requests Parameters etc.
So, Go through the Documentation of Your Needed API,
Once the Requests Are made in-app, they Generally respond you in JSON, XML etc.
Using these Incoming data you can Populate data in your APP

Get data from server in iOS

I have a script that takes hours and outputs if it is open or closed and I want to run this on my server, and then from my iOS app get if a certain place is open or closed. And I was wondering how I could do this without generating an JSON file and then parsing that as I would to frequently re-generate the file as the things change from open to closed and such. So is there a way I could make a call to the server and just get the data that I want?
Im not entirely sure whether you are asking specifically for an iOS framework for requests and responses or server side. So I figure I will try to answer both. Here are some swift projects you might be interested in. I'm not incredibly familiar with objective c yet but these resources might prove useful.
Alamofire
This will help you send and receive http requests.
Swifty JSON
This will help with JSON parsing
However if your question is more regarding server side issues. You could look into a REST api and that way you could only request certain entities that you are interested in instead of just sending back the entire batch of information with all of your data, and searching through it on the iOS device.
Hopefully this is somewhat helpful.
If you are only planning on GET-ing some content from the web you can use the NSURL class. NSURL *lru = [NSURL URLWithString:#"http:mywebserver.com"] and then create a new string object from the url with [NSString stringWithContentsOfURL:lru], or any data you would like. If you are trying to hold a session or having more control over the request, I would suggest looking into the NSURLSession class.

Using Car2go Api for iOS app

Hi I am trying to get the list of all car2go cars and use it for a test application, the only problem is I do not know how to get the information. I have gotten a consumer key and secret key but the problem is I am unsure how to get the file using the api and then once I get the file I don't know how I would read it since it is using xml.
The response from the html is on this site
http://code.google.com/p/car2go/wiki/vehicles_v2_1
once I get the file I don't know how I would read it since it is using xml
You'll need to parse the response to extract the data you want. There are a number of ways to do that. For example, you could use NSXMLParser (which is included in Cocoa Touch), or you could use the TouchXML library, or you could use libxml.

How to get data from a web service?

I'm trying to write an iOS application that'll get data from a web server and display it as I want. I want to use JSON for this purpose. But as I'm absolutely new to web apps I've got no idea how I'm going to get the url to a certain feed. Now here're the two big questions:
How do I find the url to a feed provided by a web service? Is there a standard way or is it publicly or exclusively handed to the web service subscribers?
Is the format they provide data in up to their preference (like XML or JSON)? I mean, do I choose my data parsing method according to the format the web service gives data in? So that if the feed is in XML format using NSJSONSerialization class makes no sense.
The URL to use is dependent on the web service and is usually well described in the documentation.
The type of data they return and the the structure is also usually well described in the documentation.
The common bits you'll need to know are how to get to the web-service (NSURLRequest/NSURLConnection or any of the many asynchronous wrappers that are open source and available with a bit of searching), And how to deal with the the returned data - whether it's in JSON (NSJSONSerialization, JSONKit) format or XML (NSXMLParser, libxml, or any of the many open source implementations that are available and described with a bit of searching)

Resources