https://github.com/anscoder/weatherappdemo
A simple weather demo source code in Swift 2.2 language.
https://github.com/anscoder/weatherappdemo
Last synced: 5 months ago
JSON representation
A simple weather demo source code in Swift 2.2 language.
- Host: GitHub
- URL: https://github.com/anscoder/weatherappdemo
- Owner: ANSCoder
- Created: 2016-05-31T18:47:34.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-12T18:01:29.000Z (over 9 years ago)
- Last Synced: 2025-03-21T22:22:05.633Z (10 months ago)
- Language: Swift
- Homepage:
- Size: 1.71 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Weather-App-Demo




Weather-App-Demo is an weather app demo written in Swift.
## Features
- [x] XML/Soap Parsing
- [x] Alamofire library use
- [x] SWXMLHash parser use
- [x] web view
In this demo i have added XML Parsing with Yahoo XML Api and getting weather details link and show on the
web view here.
###For Parsing i used Alamofire and for XML parsing used SWXMLHash library.
```bash
$ gem install cocoapods
```
> CocoaPods 0.39.0+ is required to build Alamofire 3.0.0+.
To integrate Alamofire and SWXMLHash into your Xcode project using CocoaPods, specify it in your `Podfile`:
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
pod 'Alamofire', :git => 'https://github.com/Alamofire/Alamofire'
pod 'SWXMLHash', :git => 'https://github.com/drmohundro/SWXMLHash'
```
Then, run the following command:
```bash
$ pod install
```
### Response Handling with the XML data
```swift
Alamofire.request(.GET, is_URL)
.responseJSON { response in
let xmls = SWXMLHash.parse(response.data!)
func enumerate(indexer: XMLIndexer, level: Int) {
for child in indexer.children {
let name:String? = child.element!.name
print("\(level) \(name)")
// Take Link from XML data here
if name! == "link" {
let text = child.element!.text
if text?.isEmpty == false{
print(text)
// Finish here Process
completion(result: text!)
}
}
enumerate(child, level: level + 1)
}
}
enumerate(xmls, level: 0)
}
}
```