Git Product home page Git Product logo

bigbrother's Introduction

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.

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

DISCLAIMER: CocoaPods doesn't officially support Swift projects yet. Use the pre-release version at your own discretion.

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

pod 'BigBrother', :git => 'https://github.com/marcelofabri/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.

bigbrother's People

Contributors

marcelofabri avatar stigi 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.