zoukankan      html  css  js  c++  java
  • object-c cocos2d-x 写程序时注意调试的技巧

    (1)写程序时最好在类的init函数中显示类名,表明现在在执行哪个类,样例代码

           CCLOG(@"cocos2d: Using Director Type:%@", [self class]);
    

    (2)最好在类中添加一个描述该类相关信息的函数,样例代码:

    - (NSString*) description
    {
    	return [NSString stringWithFormat:@"<%@ = %p | Size: %0.f x %0.f, view = %@>", [self class], self, winSizeInPoints_.width, winSizeInPoints_.height, view_];
    }
    

    (3)在每个函数中添加一个描述函数名有关的信息,样例代码:

     CCLOG(@"%@: Using Method Type:%@", [self class],[self _cmd]);
    

     (4) 对某些值可以加上断言

    NSAssert(_sharedDirector == nil, @"Attempted to allocate a second instance of a singleton.");
    

     (5)要善于运用条件编译,去调试代码

    #ifdef DEBUG
    	// If we are debugging our code
        ............................
    #endif
    

      

      

  • 相关阅读:
    php中的form表单
    http
    PHP做的简单计算器
    用Js写贪吃蛇
    ajax简单操作,验证用户名是否可以
    关于ARM PC值
    阅读脚本控制pwm代码
    编译选项
    关于机器码、原码、反码、补码
    makefile学习之函数
  • 原文地址:https://www.cnblogs.com/xiongqiangcs/p/3195897.html
Copyright © 2011-2022 走看看