Automatically sets the network activity indicator for any performed request.

Overview

BigBrother

Version Platform Build Status

BIG BROTHER IS WATCHING YOU.

BigBrother is a Swift library made for iOS that automatically watches for any performed request and sets the network activity indicator.

This is mostly a proof of concept, having several limitations because of how NSURLProtocol works. Some of them are:

It was inspired by this comment by Mattt Thompson.

It also was based on this tutorial for creating an NSURLProtocol and on AFNetworkActivityIndicatorManager from AFNetworking.

Usage

Adding

Adding to NSURLConnection and NSURLSession.sharedSession()

BigBrother.addToSharedSession()

Adding to a custom NSURLSessionConfiguration

var configuration = NSURLSessionConfiguration.defaultSessionConfiguration()

BigBrother.addToSessionConfiguration(configuration)

let session = NSURLSession(configuration: configuration)

Removing

Removing from NSURLConnection and NSURLSession.sharedSession()

BigBrother.removeFromSharedSession()

Removing from a custom NSURLSessionConfiguration

var configuration = NSURLSessionConfiguration.defaultSessionConfiguration()

BigBrother.removeFromSessionConfiguration(configuration)

let newSession = NSURLSession(configuration: configuration)

REMINDER

It is important to configure your NSURLSessionConfiguration object appropriately before using it to initialize a session object. Session objects make a copy of the configuration settings you provide and use those settings to configure the session. Once configured, the session object ignores any changes you make to the NSURLSessionConfiguration object. If you need to modify your transfer policies, you must update the session configuration object and use it to create a new NSURLSession object.

Advanced usage

BigBrother.URLProtocol is an NSURLProtocol subclass that manages the network activity indicator and it's public if you want to add it yourself to an NSURLSessionConfiguration or to the default NSURLProtocol (used by NSURLConnection and NSURLSession.sharedSession()).

BigBrother.Manager is also public, so you can manage the network activity indicator directly:

BigBrother.Manager.sharedInstance.incrementActivityCount()

// do something...

BigBrother.Manager.sharedInstance.decrementActivityCount()

Installation

BigBrother is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'BigBrother'

Then run pod install with CocoaPods 0.36 or newer.

Unit Tests

Unit testing is done with XCTest and the tests are available under the BigBrotherTests folder.

Collaborating

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request. They're more than welcome!

Contact

Marcelo Fabri

License

BigBrother is available under the MIT license. See the LICENSE file for more info.

You might also like...
An Generic HTTP Request Library For Swift

GRequest An HTTP request library written in Swift. ##Basic Usage Be simple, as it should be: Request("https://api.github.com/repos/lingoer/SwiftyJSON/

YTKNetwork is a high level request util based on AFNetworking.

YTKNetwork What YTKNetwork is a high level request util based on AFNetworking. It's developed by the iOS Team of YuanTiKu. It provides a High Level AP

An iOS library to route API paths to objects on client side with request, mapping, routing and auth layers

WANetworkRouting Developed and Maintained by ipodishima Founder & CTO at Wasappli Inc. Sponsored by Wisembly A routing library to fetch objects from a

Request adapter for URL requests from "MovieLister" demo app (Swift for Good book, a chapter by Ben Scheirman)

RequestAdapter Request adapter for URL requests from "MovieLister" demo app (Swift for Good book, a chapter by Ben Scheirman) The code is taken from:

Minimalist HTTP request library via async / await

Making HTTP API requests in Swift using Foundation can be verbose and use a mix of types like URL, URLComponents and URLRequest to form a request and then handling all the encoding and decoding steps later

iONess is HTTP Request Helper for iOS platform used by HCI iOS App

iONess iONess (iOS Network Session) is HTTP Request Helper for the iOS platform used by Home Credit Indonesia iOS App. It uses Ergo as a concurrent he

Deal with query items, HTTP headers, request body and more in an easy, declarative way

Reusable system for complex URL requests with Swift. Deal with query items, HTTP headers, request body and more in an easy, declarative way. Check out our engineering blog to learn more!

❌📱 A little swift Internet error status indicator using ReachabilitySwift

EFInternetIndicator Requirements Xcode 8.0+ iOS 8.3+ WARNING : It's not work on simulator. #1 Installation CocoaPods You can use CocoaPods to install

StatusBarOverlay will automatically show a
StatusBarOverlay will automatically show a "No Internet Connection" bar when your app loses connection, and hide it again. It supports apps which hide the status bar and The Notch

StatusBarOverlay StatusBarOverlay will automatically show a "No Internet Connection" bar when your app loses connection, and hide it again. It support

Owner
Marcelo Fabri
Marcelo Fabri
DBNetworkStack is a network abstraction for fetching request and mapping them to model objects

DBNetworkStack Main Features ?? Typed network resources ?? Value oriented architecture ?? Exchangeable implementations ?? Extendable API ?? Composable

DB Systel GmbH 33 Jan 10, 2022
Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application.

Another network wrapper for URLSession. Built to be simple, small and easy to create tests at the network layer of your application. Install Carthage

Ronan Rodrigo Nunes 89 Dec 26, 2022
A network extension app to block a user input URI. Meant as a network extension filter proof of concept.

URIBlockNE A network extension app to block a user input URI. Meant as a network extension filter proof of concept. This is just a research effort to

Charles Edge 5 Oct 17, 2022
Say goodbye to the Fat ugly singleton Network Manager with this Network Layer

MHNetwork Protocol Oriented Network Layer Aim to avoid having bloated singleton NetworkManager Philosophy the main philosophy behind MHNetwork is to h

Mohamed Emad Hegab 19 Nov 19, 2022
NWReachability - a pure Swift library for monitoring the network connection of iOS devices using Apple's Network framework.

NWReachability is a pure Swift library for monitoring the network connection of iOS devices using Apple's Network framework.

null 4 Dec 2, 2022
Easy and lightweight network layer for creating different set of network requests like GET, POST, PUT, DELETE customizable with coders conforming to TopLevelDecoder, TopLevelEncoder

Easy and lightweight network layer for creating different set of network requests like GET, POST, PUT, DELETE customizable with coders conforming to TopLevelDecoder, TopLevelEncoder

Igor 2 Sep 16, 2022
Type-safe networking abstraction layer that associates request type with response type.

APIKit APIKit is a type-safe networking abstraction layer that associates request type with response type. // SearchRepositoriesRequest conforms to Re

Yosuke Ishikawa 1.9k Dec 30, 2022
This package is meant to make http request of an easy way inspiren in the architecture of Moya package

NetworkAgent This package is meant to make http request of an easy way inspiren in the architecture of Moya package. This package is 100% free of depe

Angel Rada 19 Sep 8, 2022
Minimalistic Swift HTTP request agent for iOS and OS X

Agent Table of Contents Introduction Usage HTTP Verbs Overloading Method Chaining Response Closure Verbs Methods NSMutableURLRequest Contributing Lice

null 589 Jun 29, 2022
Http Request wrapper written in Swift

Net Net is a HttpRequest wrapper written in Swift Features GET, POST, PUT, DELETE method Powerful request params: nested params, number, string, dic,

Le Van Nghia 304 Jun 29, 2022