一点一滴,编程人生

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  69 随笔 :: 0 文章 :: 25 评论 :: 0 Trackbacks
three20 wiki 地址:https://github.com/facebook/three20/wiki/Debugging

You can use Three20's debugging facilities instead of NSLog() / assert(). This would give you an ability to turn off debugging messages without commenting out all NSLog's, sort log messages by importance (errorwarninginfo).

Turn on debugging(打开调试)

These instructions are for Xcode 3:

  • Right-click on project, choose "Get Info".
  • In the "Build" tab, choose "Configuration => Debug" (you probably want to enable this only for debug builds)
  • While in the "Build" tab, search for "Preprocessor Macros" under the "GCC 4.2 - Preprocessing" section.
    • Add a declaration that reads DEBUG. That way you enable debugging in general.
    • Add a declaration that reads TTMAXLOGLEVEL=TTLOGLEVEL_INFO. By doing this, you set the default debugging output to beTTLOGLEVEL_INFO, the most descriptive one.

Debugging preprocessor macro

Use debugging

Logging

Use these instead of NSLog(). Which level gets printed to the console and which doesn't depends on what's set in preprocessor macros asTTMAXLOGLEVEL (see above).

TTDERROR(text, ...)    // Log level 1 TTDWARNING(text, ...)  // Log level 3 TTDINFO(text, ...)     // Log level 5 TTDPRINT(text, ...) 

Example

If I got this in AppDelegate.m of my project HelloWorld:

- (void)applicationDidFinishLaunching:(UIApplication *)application {	     TTDINFO(@"Hello!"); } 

...the console output would look like this:

2010-05-15 01:04:20.107 HelloWorld[65222:207] -[AppDelegate applicationDidFinishLaunching:](22): Hello! 

Conditional logging

This is a type of logging facility which only outputs something if a particular condition is met:

TTDCONDITIONLOG(condition, text, ...); 

Example

TTDCONDITIONLOG(TTDFLAG_URLREQUEST, @"Request parameters: %@", request.parameters); 

Debug-only assertions

Three20 also provides support for assertions which only work in the debug build.

TTDASSERT(condition_which_would_lead_to_application_termination_when_true); 

Example

// Not that implementing safeAddSubview: is a good idea - (void)safeAddSubview:(UIView*)view {     TTDASSERT(nil != view);     if (nil == view) {         return;     }     [self addSubview:view]; } 

See also

Links

posted on 2012-09-27 10:30 writegull 阅读(396) 评论(0)  编辑  收藏 所属分类: iphone

只有注册用户登录后才能发表评论。


网站导航: