一點一滴,編程人生

            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 閱讀(408) 評論(0)  編輯  收藏 所屬分類: iphone
          主站蜘蛛池模板: 五莲县| 广水市| 蓬溪县| 齐齐哈尔市| 苗栗县| 聊城市| 新和县| 湖北省| 桂阳县| 靖安县| 海原县| 衢州市| 仙桃市| 易门县| 岳池县| 遂溪县| 紫金县| 泰宁县| 双鸭山市| 富锦市| 德令哈市| 新丰县| 常山县| 治多县| 老河口市| 广水市| 漳平市| 临漳县| 盖州市| 桃园县| 吉隆县| 慈溪市| 读书| 成都市| 沈阳市| 改则县| 卓尼县| 集贤县| 庆云县| 北流市| 昭通市|