- Swift 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| OpenTransportSwissDepartures | ||
| OpenTransportSwissDepartures.xcodeproj | ||
| LICENSE | ||
| README.md | ||
About
This iOS project brings you up to speed in using the live arrivals/departures APIs provided by Open Data Platform Swiss Public Transport portal.
The project is developed with Xcode 8.1, Swift 3.x and supports iOS 8.4+ devices
Setup
- clone / download / unzip a copy of this repo on your machine
- get a free API key from opentransportdata.swiss
- add your key inside OpenTransportSwissDepartures/ViewController.swift
- build and run, you should see the departures for Zürich HB, stop_id = 8503000
Include the code in your project
In the near future we will offer iOS framework or 3rd party CocoaPods/Carthage library support. Until then you have to import the library manually:
- copy
OpenTransportSwissDepartures/ODPSwiss/*files in your project - make sure the files are added to your app main target
- instantiate
ODPSwissDeparturesNetworkControllerobject in the VC with your API token - call the
fetchDeparturesForStopIdon a background thread and use the result array which is of typeODPCH_TripDeparture.
DispatchQueue.global(qos: .background).async { self.networkController?.fetchDeparturesForStopId(stopId: stopId, handler:{ (newDepartures) in DispatchQueue.main.async(){ // DO something with newDepartures } }) }
- check ODPSwissModels.swift for more info about the GTFS and ODPCH models used
Contact
For questions related to OpenData APIs please contact ODPCH team
Do you want to contribute to this project? Please send us your feedback or even better, a pull request!
Contributors:
License
This project is licensed under the terms of the MIT license. See the LICENSE file.
This project is open source under the MIT license, which means you have full access to the source code and can modify it to fit your own needs. You are fully responsible for how you use this project.