484Printing Selectors in NSLog
Using NSStringFromSelector to convert the selectos into a NSString, and the print the object:
NSLog(@"%@", NSStringFromSelector(selector) );
Or print it directly with good, old-fashioned C:
NSLog(@"%s", selector,);
Using NSStringFromSelector to convert the selectos into a NSString, and the print the object:
NSLog(@"%@", NSStringFromSelector(selector) );
Or print it directly with good, old-fashioned C:
NSLog(@"%s", selector,);
int x = 11; [NSString stringWithFormat:@"%03i", x]; // @"011" [NSString stringWithFormat:@"%+5i", x]; // @"+++11" [NSString stringWithFormat:@"%+05i", x]; // @"+0011"
And not really like that. 381. I’ll still have to learn a lot of C.
Add the the *_Prefix.pch file of your projects. Strips out NSLogs, when optimized (=Release Build)
Very nice solution, thanks to Marek Bell
// strip out NSLog on optimize #ifndef __OPTIMIZE__ # define NSLog(...) NSLog(__VA_ARGS__) #else # define NSLog(...) {} #endif
float f = 1.23456; NSLog(@"%.2f", f); NSLog(@"%.0f", f); NSLog(@"%.0f", f);
1.23
1
1.23456
Looking Projectwide for NSLog’s:
Shift-Apple-F: [^//]NSLog
All the NSLogs, which don’t have // infront of them.
Update:
This might be a more elegant way to get rid of the NSLogs. 447
Turning Boolean 1, 0 into a more descriptive description:
NSLog(@”data1 is equal to data2: %@”, [data1 isEqualToData:data2] ? @”YES” : @”NO”);