IOS用NSLog做 debug调试

-(id) initWithPlayer:(VVPlayer *)aPlayer seatsNum:(int)seatsNum
{ 

    if (self = [super init])
    {
      NSLog(@”
 Function: %s
 Pretty function: %s
 Line: %d
 File: %s
 Object: %@”,__func__, __PRETTY_FUNCTION__, __LINE__, __FILE__, aPlayer);  
    }
…
}

__func__ __PRETTY_FUNCTION__ __LINE__ __FILE__都是系统预留的定义词,简单易用

另外还有一些Core Foundation的方法可以从CFString的层级拿到一些有用的字符串,包括且不限于selector、class、protocol等

-(id) initWithPlayer:(VVPlayer *)aPlayer seatsNum:(int)seatsNum
{ if (self = [super init])
{
NSLog(@”Current selector: %@”, NSStringFromSelector(_cmd));  
NSLog(@”Object class: %@”, NSStringFromClass([self class]));  
NSLog(@”Filename: %@”, [[NSString stringWithUTF8String:__FILE__] lastPathComponent]);  
}
…
}
原文地址:https://www.cnblogs.com/luseike/p/4073268.html