Giter VIP home page Giter VIP logo

mcdebuggingtools's Introduction

MCDebuggingTools - Extermination helper

Badge w/ Version Badge w/ Platform

Collection of debuging tools that can be added to your project

Usage

#import "AppDelegate.h"
#import "MCMemoryWarningGenerators.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
#ifdef DEBUG
  // Force memory warnings to occur every 60 seconds. Helps you ensure you're
  // handling them properly.
  PERFORM_MEMORY_WARNING_AT_INTERVAL(60);
#endif


#ifdef DEBUG
  // Allocate a block of memory every 30 seconds. Helps ensure your application
  // can survive low memory conditions.
  ALLOCATE_MEMORY_BLOCK_AT_INTERNAL(30);
#endif

  return YES;
}

MCMemoryWarrningGenerator

Extremely simple to use tool to simulate low memory conditions in your application so you can ensure that it behaves correctly when receiving memory warnings.

// generates a simulated memory warning continuously at the specified interval
// in seconds.
PERFORM_MEMORY_WARNING_AT_INTERVAL(interval);
// Allocates blocks of 5MB of memory continuously at the specified interval
// in seconds.
ALLOCATE_MEMORY_BLOCK_AT_INTERNAL(interval)

MCServerEnvironment

MCServerEnvironment helps to switch client base URL easily.

// Before initializing your MCServerEnvironment and client objects,
// create every URLs needed for your environment switcher
NSURL *devURL = [NSURL URLWithString:@"http://localhost"];
NSURL *ciURL = [NSURL URLWithString:@"http://api.yourserver.ci.com/"];
NSURL *qaURL = [NSURL URLWithString:@"http://api.yourserver.qa.com/"];
NSURL *stagingURL = [NSURL URLWithString:@"http://api.yourserver.staging.com/"];
NSURL *productionURL = [NSURL URLWithString:@"http://api.yourserver.prod.com/"];

// A default URL is required at MCServerEnvironment initialization
NSURL *defaultURL = nil;

#ifdef PROD_API
    defaultURL = stagingURL;
#elif STAGING_API
    defaultURL = stagingURL;
#elif QA_API
    defaultURL = qaURL;
#elif DEBUG
    defaultURL = ciURL;
#endif

// Create MCServerEnvironment object with needed URLs
_serverEnvironment = [[MCServerEnvironment alloc] initWithDefaultURL:defaultURL developmentURL:nil ciURL:ciURL qaURL:qaURL stagingURL:stagingURL productionURL:productionURL otherURLs:nil];

// Create your client object with MCServerEnvironment URL method
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:[_serverEnvironment URL]];
// Required
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    // Tell MCServerEnvironment an URL Scheme has been called and give it a presenter view controller
    // If the URL host is equals to "env", a view controller will be presented
    [_serverEnvironment openURL:url presenterViewController:self.window.rootViewController completionBlock:nil];
    return YES;
}

// Optional
- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // This will show an alert for 3 seconds with the setted base URL if it's not the default
    [_serverEnvironment showDebugAlert];
}

Adding to your project

If you're using CocoaPods, there's nothing simpler. Add the following to your Podfile and run pod install.

pod 'MCDebuggingTools', :git => 'https://github.com/mirego/MCDebuggingTools.git'

Don't forget to #import "MCMemoryWarningGenerators.h" where it's needed.

License

MCDebuggingTools is © 2013-2015 Mirego and may be freely distributed under the New BSD license. See the LICENSE file.

About Mirego

Mirego is a team of passionate people who believe that work is a place where you can innovate and have fun. We're a team of talented people who imagine and build beautiful Web and mobile applications. We come together to share ideas and change the world.

We also love open-source software and we try to give back to the community as much as we can.

mcdebuggingtools's People

Contributors

flambert avatar marclefrancois avatar p-l avatar remi 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.