a collection of macros and other helpers that have made developing in objective-c and iOS less excruciating.
- VERBOSE_NSLOG: if set to 1, this will add the filename and line num to NSLog calls
- SILENCE_NSLOG: if set to 1, all calls to NSLog become no-ops
- LOG_MACROS_ARE_ACTIVE: easily turn off all changes to logging
- NSLOG_TO_TESTFLIGHT: redirect all
NSLog()
calls toTFLog()
, which sends them to TestFlight - AUTOMATIC_LOG_COLORS: automatically colorize
NSLog()
(orBrynLog()
, as the case may be) output in the xcode console
these macros are intended to make using the XcodeColors plugin (DeepIT/XcodeColors) easier.
These macros evaluate to a regular NSString literal, so you can simply concatenate them into an NSString expression like so:
NSLog(@"Blah blah" COLOR_RED @"This will be red" XCODE_COLORS_RESET @"This will not");
COLOR_RED
COLOR_YELLOW
COLOR_OLIVE
COLOR_GREEN
COLOR_PURPLE
COLOR_BLUE
These are actual #define
macros, accepting an NSString *
argument. The
reason is that they add an XCODE_COLORS_RESET
after the passed argument.
COLOR_ERROR(str)
COLOR_SUCCESS(str)
COLOR_FILENAME(str)
COLOR_LINE(str)
COLOR_FUNC(str)
For example:
NSLog(COLOR_ERROR(@"You screwed up") @"... but it'll be okay.");
the built-in macro __FILE__
contains the entire path to a
file. you don't often want that. this just gives you the file's actual name.
this is the macro that replaces NSLog
if you have VERBOSE_NSLOG
set to 1. if
you want to use it without replacing NSLog
, leave VERBOSE_NSLOG
set to 0 and
just call BrynLog
. same syntax as NSLog()
.
just like BrynLog/NSLog except that it prefixes the log message with the function/selector name instead of the file and line num.
load a PNG file from the main bundle. people use +[UIImage imageNamed:]
because it's much easier than the (minimum) method calls you have to make to
load a UIImage
the 'right' way. with a macro like this, there's no excuse.
note: the image filename you pass to this macro should not contain its file
extension (".png").
calls [array objectAtIndex:index]
, but first checks to make sure that the
array contains enough elements to even HAVE an object at the given index.
warning: you may fail to notice bugs in your code when using this macro.
exceptions get thrown for a reason, y'heard?
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <[email protected]>
Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- You just DO WHAT THE FUCK YOU WANT TO.