Giter Club home page Giter Club logo

seismicxml-swift's Introduction

SeismicXML

Description

The SeismicXML sample application demonstrates how to use NSXMLParser to parse XML data. When you launch the application it downloads and parses an RSS feed from the United States Geological Survey (USGS) that provides data on recent earthquakes around the world. It displays the location, date, and magnitude of each earthquake, along with a color-coded graphic that indicates the severity of the earthquake. The XML parsing occurs on a background thread and updates the earthquakes table view with batches of parsed objects.

It uses NSURLSession to asynchronously download the data. This means the main thread will not be blocked - the application will remain responsive to the user. When the app is sent to the background, the connection is cancelled.

The USGS feed is at "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.quakeml" and includes all recent magnitude 2.5 and greater earthquakes world-wide, representing each earthquake with an element. The QuakeML spec is defined at "https://quake.ethz.ch/quakeml/"."

NSXMLParser is an "event-driven" parser. This means that it makes a single pass over the XML data and calls back to its delegate with "events". These events include the beginning and end of elements, parsed character data, errors, and more. In this sample, the application delegate, an instance of the "SeismicXMLAppDelegate" class, also implements the delegate methods for the parser object. In these methods, Earthquake objects are instantiated and their properties are set, according to the data provided by the parser. For some data, additional work is required - numbers extracted from strings, or date objects created from strings.

Main Classes

APLViewController A UITableViewController subclass that manages the table view; initiates the download of the XML data and parses the Earthquake objects at view load time.

APLParseOperation The NSOperation class used to perform the XML parsing of earthquake data.

APLEarthquake Simple model class to hold information about an earthquake.

Requirements

Build

iOS 9.0 SDK or later

Runtime

iOS 8.0 or later.

Copyright (C) 2008-2015 Apple Inc. All rights reserved.

seismicxml-swift's People

Contributors

ooper-shlab avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.