Latest 0.2.0
Homepage https://github.com/kahopoon/youbike
License MIT
Platforms ios 10.0
Authors

youbike for iOS project

You can now get the youbike realtime info in a very easy way.
According to available open data from TW Gov, for now, support cities are: Taipei, New Taipei, Taoyuan, Taichung.

Installation

Cocoapods

pod 'youbike'

At xcode project

import youbike

At Info.plist, add these urls to ‘Exception Domains’ at ‘App Transport Security Settings’

data.tycg.gov.tw
data.taipei
data.ntpc.gov.tw
ybjson01.youbike.com.tw:1002

Usage

Get all station

youbike.station.all { (stations) in
    // all stations array
}

Specific city

youbike.station.taoyuan { (stations) in
    // taoyuan stations array
}

Specific cities

youbike.station.with(locations: [.Taipei, .Taoyuan]) { (stations) in
    // taipei and taoyuan stations array    
}

Search nearest / result limit

let taoyuanArena = CLLocationCoordinate2D(latitude: 24.9950114,longitude: 121.3229133)
youbike.station.all(withCount: 5, nearest: taoyuanArena) { (stations) in
    // 5 result that near taoyuan arena
}
youbike.station.taoyuan(withCount: 5, nearest: taoyuanArena) { (stations) in
    // as same as previous one ideally...:p
}
youbike.station.taoyuan(nearest: taoyuanArena) { (stations) in
    // all taoyuan stations sorted with taoyuan arena
}
youbike.station.taoyuan(nearest: taoyuanArena) { (stations) in
    // all stations sorted with taoyuan arena
}

Station update

youbike.station.update(fromStation: <#station#>) { (station) in
    // update for station
}

Auto Update

Start fetch

youbike.autoUpdate.startUpdating()

Updated result (default: per minute, all stations)

youbike.autoUpdate.updatedStations()

Stop fetch

youbike.autoUpdate.stopUpdating()

Auto Update Settings

Location based limit result

youbike.autoUpdate.startUpdating(location: [.Taoyuan], withCount: 3, nearest: taoyuanArena, interval: 2) //3 result near taoyuan arena at taoyuan, update every 2 mins

Change settings while updating

youbike.autoUpdate.count(5) // set result limit to 5
youbike.autoUpdate.interval(minute: 5) // set update interval to 5 mins
youbike.autoUpdate.nearest(CLLocationCoordinate2D) // set nearest location
youbike.autoUpdate.with(location: [location]) // set cities

Latest podspec

{
    "name": "youbike",
    "version": "0.2.0",
    "summary": "Get Taiwan's youbike realtime information with no pain!",
    "description": "For API documentations, please refer to github project page readme.",
    "homepage": "https://github.com/kahopoon/youbike",
    "license": {
        "type": "MIT"
    },
    "authors": {
        "kahopoon": "[email protected]"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/kahopoon/youbike.git",
        "tag": "0.2.0"
    },
    "source_files": "youbike/*.{swift,plist,h}",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This