Skip to content

shamanskyh/NextBusKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NextBusKit

A simple API wrapper in Swift for NextBus transit information.

Examples

Initialize a transit Agency:

let agency = Agency(tag: "sf-muni", title: "San Francisco Municipal Railway", regionTitle: "California-Northern")

Get an Agency's routes:

do {
    let nJudah = try agency.routes().filter({ $0.tag == "N" })
} catch {
    fatalError()
}

Get Predictions for a Stop:

do {
    let powellOutbound = Stop(agency: agency, stopTag: "6995", title: "Powell Station Outbound", location: (37.7843, -122.4078199), stopId: "16995")
    let (predictions, _) = try powellOutbound.predictions()
} catch {
    fatalError()
}

Important Notes

Unless otherwise marked, calls should be assumed to be synchronous. It's a good idea to dispatch to a background queue, query routes/stops, then dispatch back to main when you're ready to update your UI.