Latest 0.3.1
Homepage https://github.com/ymyzk/NetworkActivityIndicatorManager
License MIT
Platforms ios 8.0
Frameworks Foundation, UIKit
Authors

Build Status
CocoaPods
Carthage compatible
Platform

NetworkActivityIndicatorManager is a manager library of the network activity indicator in the status bar.

Install

Carthage

Add NetworkActivityIndicatorManager to your Cartfile (package dependency) or Cartfile.private (development dependency):

github "ymyzk/NetworkActivityIndicatorManager"

CocoaPods

Add NetworkActivityIndicatorManager to your Podfile.

use_frameworks!

pod 'NetworkActivityIndicatorManager', '~> 0.3'

Usage

Manually

import NetworkActivityIndicatorManager

let manager = NetworkActivityIndicatorManager.sharedManager

manager.increment()
// Some networking operations here
manager.decrement()

Notifications

By sending notifications, you can increment/decrement the counter.

import NetworkActivityIndicatorManager

let manager = NetworkActivityIndicatorManager.sharedManager

let incrementNotification = "increment"
let decrementNotification = "decrement"

manager.registerForIncrementNotification(incrementNotification)
manager.registerForDecrementNotification(decrementNotification)

NSNotificationCenter.defaultCenter().postNotificationName(incrementNotification, object: nil)
// Some networking operations here
NSNotificationCenter.defaultCenter().postNotificationName(decrementNotification, object: nil)

Some libraries send notifications on start/end network activities.

AFNetworking

import AFNetworking
import NetworkActivityIndicatorManager

let manager = NetworkActivityIndicatorManager.sharedManager
manager.registerForIncrementNotification(AFNetworkingTaskDidResumeNotification
manager.registerForDecrementNotification(AFNetworkingTaskDidSuspendNotification)
manager.registerForDecrementNotification(AFNetworkingTaskDidCompleteNotification)

Alamofire

import Alamofire
import NetworkActivityIndicatorManager

let manager = NetworkActivityIndicatorManager.sharedManager
manager.registerForIncrementNotification(Notifications.Task.DidResume)
manager.registerForDecrementNotification(Notifications.Task.DidSuspend)
manager.registerForDecrementNotification(Notifications.Task.DidComplete)

SDWebImage

import NetworkActivityIndicatorManager
import SDWebImage

let manager = NetworkActivityIndicatorManager.sharedManager
manager.registerForIncrementNotification(SDWebImageDownloadStartNotification)
manager.registerForDecrementNotification(SDWebImageDownloadStopNotification)

License

MIT License. See LICENSE for more information.

Latest podspec

{
    "name": "NetworkActivityIndicatorManager",
    "version": "0.3.1",
    "summary": "A manager library of the network activity indicator.",
    "description": "NetworkActivityIndicatorManager is a manager library of the network activity indicator in the status bar.",
    "homepage": "https://github.com/ymyzk/NetworkActivityIndicatorManager",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Yusuke Miyazaki": "[email protected]"
    },
    "social_media_url": "https://twitter.com/ymyzk",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/ymyzk/NetworkActivityIndicatorManager.git",
        "tag": "v0.3.1"
    },
    "source_files": "Source/*.{h,m,swift}",
    "public_header_files": "Source/*.h",
    "frameworks": [
        "Foundation",
        "UIKit"
    ]
}

Pin It on Pinterest

Share This