首页 > 代码库 > IOS用NSLog做 debug调试

IOS用NSLog做 debug调试

-(id) initWithPlayer:(VVPlayer *)aPlayer seatsNum:(int)seatsNum{     if (self = [super init])    {      NSLog(@”\n Function: %s\n Pretty function: %s\n Line: %d\n File: %s\n 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]);  }…}

 

IOS用NSLog做 debug调试