(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