• This repository has been archived on 26/Sep/2022
  • Stars
    star
    446
  • Rank 97,888 (Top 2 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 10 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Automatically sets the network activity indicator for any performed request.

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!

License

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

More Repositories

1

xcpretty-json-formatter

xcpretty custom formatter for parsing warnings and errors easily from a JSON
Ruby
41
star
2

Staged

Mock View Controllers presentations and dismissals on unit tests
Objective-C
19
star
3

IBOutlint

Xcode plugin to change the order of the attributes when creating an IBOutlet in Xcode
Objective-C
17
star
4

app-store-manifesto

A manifesto for developers make a better App Store
14
star
5

articles

Articles and tutorials written by me
8
star
6

DecksetExport

A CLI for for generating PDFs from Markdown presentations created with Deckset.
Swift
8
star
7

movile-up

Swift
6
star
8

cocoapods-clang-format-hook

Easily setup a git pre-commit hook to validate your code.
Ruby
5
star
9

BorderedView

An UIView subclass (in Swift) with corner radius, border width and border color configurable on Interface Builder.
Swift
5
star
10

randomiostips

3
star
11

flws-folha-safari

Continue lendo notícias da Folha no Safari depois do limite mensal.
JavaScript
3
star
12

danger-simplecov_json

Report your Ruby app test suite code coverage.
Ruby
3
star
13

UIView-UIImageEffects

Create blurred images from an UIView
Objective-C
3
star
14

deploymate-to-pmd

Generates a PMD report from a JSON generated from Deploymate
Python
2
star
15

Xcode-Snapshots-Specta-Templates

Xcode file template for snapshots unit tests using Specta and Expecta matchers
2
star
16

Xcode-Expecta-File-Template

Xcode file template for unit tests using Expecta
2
star
17

MFBBlurredTransition

Present modal view controllers with blur behind them.
Objective-C
2
star
18

mc959

Python
1
star
19

OverlayView

Swift
1
star
20

mc437

JavaScript
1
star
21

cocoapods-rss-example

Swift
1
star
22

cocoapods-scoped-keys

Ruby
1
star