Codec ░ NSLog

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,);

565Stripping Characters from an NSString 564NSData to NSString and vice versa 452Padding with Zeros (or other characters) 447Stripping out NSLog() from the Release Build 383String By Appending Path Component

452Padding with Zeros (or other characters)

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.

640printf()ing string in C++ 632Inline Functions in C 565Stripping Characters from an NSString 564NSData to NSString and vice versa 484Printing Selectors in NSLog

447Stripping out NSLog() from the Release Build

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

484Printing Selectors in NSLog 452Padding with Zeros (or other characters) 376Variable length of accuracy of float in NSString 287[^//]NSLog 218Obj-C, Shortcut: Boolean return value to String

376Variable length of accuracy of float in NSString

float f = 1.23456;
 
NSLog(@"%.2f", f);
NSLog(@"%.0f", f);
NSLog(@"%.0f", f);

1.23
1
1.23456

565Stripping Characters from an NSString 564NSData to NSString and vice versa 484Printing Selectors in NSLog 452Padding with Zeros (or other characters) 447Stripping out NSLog() from the Release Build

287[^//]NSLog

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

484Printing Selectors in NSLog 452Padding with Zeros (or other characters) 447Stripping out NSLog() from the Release Build 376Variable length of accuracy of float in NSString 218Obj-C, Shortcut: Boolean return value to String

218Obj-C, Shortcut: Boolean return value to String

Turning Boolean 1, 0 into a more descriptive description:

NSLog(@”data1 is equal to data2: %@”, [data1 isEqualToData:data2] ? @”YES” : @”NO”);

569Layering one UIImage onto of another UIImage 560#import vs #include in Objective C – A quick reminder 484Printing Selectors in NSLog 457Singleton Classes and Shared Resources in Objective-C 452Padding with Zeros (or other characters)