一點(diǎn)一滴,編程人生

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            69 隨筆 :: 0 文章 :: 25 評(píng)論 :: 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(打開調(diào)試)

          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) 評(píng)論(0)  編輯  收藏 所屬分類: iphone
          主站蜘蛛池模板: 即墨市| 舒城县| 比如县| 荔波县| 庆阳市| 西宁市| 嘉定区| 阜康市| 若羌县| 登封市| 蓝田县| 蕲春县| 梁河县| 安多县| 昭苏县| 封丘县| 惠水县| 陆良县| 浦县| 鄯善县| 根河市| 桐乡市| 射阳县| 新乡县| 鄂伦春自治旗| 龙山县| 渝中区| 十堰市| 微山县| 南和县| 凉山| 晋宁县| 枝江市| 泽普县| 西充县| 嘉兴市| 洛川县| 海兴县| 澄迈县| 双柏县| 密云县|