jean-melikian / silverplate-ios

A system event helper for iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SilverPlate Framework Build Status


Description

SilverPlate is a Swift3 framework which elegantly brings some of the most important system events to you.

Easy to use, you do not need protocols/delegates nor to implement a gazillion methods into your neat classes as the SilverPlate public API relies on simple closures.


Implementation

  • In a ViewController or any other class, to respond to reachability status change:
import UIKit
import SilverPlate

class ViewController: UIViewController {
    @IBOutlet weak var netStatusLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
        SilverPlate.shared.onInternetStatusChanged = { (status) in
            self.netStatusLabel.text = "Connectivity status: \(status)"

            switch status {
            case SilverPlate.Network.wifi:
                // Do some heavy download
                break
            case SilverPlate.Network.cellular:
                // Now easy with the data load
                break
            case SilverPlate.Network.none:
                // Don't try to fetch anything from the web
                break
            }
        }
    }
}

About

A system event helper for iOS

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Swift 53.5%Language:Ruby 42.1%Language:Objective-C 2.7%Language:Shell 1.8%