SODA SDK for Apples Swift programming language http://socrata.github.io/soda-swift/

3997
    


来源:
Licence:
联系:
分类:
平台:
环境:
大小:
更新:
标签:
联系方式 :
免费下载 ×

下载APP,支持永久资源免费下载

限免产品服务请联系qq:1585269081

下载APP
免费下载 ×

下载APP,支持永久资源免费下载

下载APP 免费下载
下载 ×

下载APP,资源永久免费


如果出现不能下载的情况,请联系站长,联系方式在下方。

免费下载 ×

下载论文助手APP,资源永久免费

免费获取

如果你已经登录仍然出现不能下载的情况,请【点击刷新】本页面或者联系站长


soda-swift soda-swift is a native Swift library to access Socrata OpenData servers. It is compatible with iOS 8 and OS X 10.10. Getting Started 1. Get an access token for your app 2. Reference SODAKit/SODAClient.swift in Xcode 3. Initialize a SODAClient let client = SODAClient(domain: "(Domain name of the server)", token: "(Your apps access token)") For example, let client = SODAClient(domain: "data.cityofchicago.org", token: "Uo25eXiX14zEd2K6EKAkeMIDW") (that token wont work) 4. Query for data Here is a simple filter query to find compressed natural gas stations in Chicago: let fuelLocations = client.queryDataset("alternative-fuel-locations") fuelLocations.filterColumn ("fuel_type_code", "CNG").get { res in switch res { case .Dataset (let data): // Display the data case .Error (let error): // Show the error } } Note the use of filterColumn to get only compressed natural gas stations. Also note that the final get function is asynchronous and that the last argument is a completion handler. For your convenience, soda-swift automatically schedules the handler on the main operation queue. That completion handler is given an enumeration SODADatasetResult with two possible values: Dataset with an array of rows if the query succeeded. Error with the NSError if the query failed. Query Options There are many more query options than just filterColumn . We could have also written: fuelLocations.filter("fuel_type_code = CNG") We can also order the results: fuelLocations.orderAscending("station_name") We can then limit the results and control the offset to perform paging: fuelLocations.limit(10).offset(0) Chaining Queries Queries can be easily composed and stored in variables. This allows you to keep your code clean and easily construct derivative queries. For example, we may have an app that has a base query called fuelLocations : let fuelLocations = client.queryDataset("alternative-fuel-locations") The app allows the user to choose two types of stations: natural gas and electric. This decision is encapsulated in the query stations . let userWantsNaturalGas = true // Get this from the UI let stations = fuelLocations.filterColumn("fuel_type_code", userWantsNaturalGas ? "CNG" : "ELEC") The app can also display the data sorted in two different directions and stores this in orderedStations : let userWantsAscending = true // Get this from the UI let orderedStations = userWantsAscending ? stations.orderAscending("station_name") : stations.orderDescending("station_name") Now the app can easily query the results: orderedStations.get { result in // Display the data or the error } API Reference The full API Reference can be found in Reference.md . Sample App A sample app that shows alternative fuel locations in Chicago is included. Open soda-swift.xcodeproj Modify SODASample/AppDelegate.swift to insert your access token Ensure that the target SODASample is selected Run


免费下载 ×

下载APP,支持永久资源免费下载

下载APP 免费下载
温馨提示
请用电脑打开本网页,即可以免费获取你想要的了。
扫描加我微信 ×

演示

×
登录 ×


下载 ×
论文助手网
论文助手,最开放的学术期刊平台
				暂无来源信息			 
回复
来来来,吐槽点啥吧

作者联系方式

×

向作者索要->