mirego/MCDebuggingTools

语言: Objective-C

git: https://github.com/mirego/MCDebuggingTools

一系列很酷的调试工具
A collection of cool debugging tools
README.md (中文)

MCDebuggingTools - 灭绝助手

Badge w/ Version
Badge w/ Platform

可以添加到项目中的调试工具的集合

用法

#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

非常简单易用的工具来模拟你的低内存条件 应用程序,以便您可以确保它在接收内存时正常运行 警告。

// 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有助于轻松切换客户端基本URL。

// 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];
}

添加到您的项目

如果你正在使用CocoaPods,那就没什么比这更简单了。 将以下内容添加到Podfile中 并运行pod安装。

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

不要忘记在需要的地方#import“MCMemoryWarningGenerators.h”。

执照

MCDebuggingTools是©2013-2015 Mirego,可能是免费的 根据新BSD许可证分发。 请参阅LICENSE文件。

关于Mirego

Mirego是一群充满激情的人,他们相信工作是一个可以创新和享受乐趣的地方。我们是一群有才华的人,他们想象并构建漂亮的Web和移动应用程序。我们聚在一起分享想法,改变世界。

我们也喜欢开源软件,我们尽可能地回馈社区。

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

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.