4 ms·
The Most Useful Objective-C Code I’ve Ever Written
- Hoff 16y agoHere's the Borkware NSLog replacement: http://www.borkware.com/rants/agentm/mlog/ http://www.borkware.com/rants/agentm/mlog/ There are others.
- Zev 16y agoThe Borkware NSLog replacement seems like a rather a large amount of overkill and unnecessary clutter. __FILE__ and __LINE__ should always be implicit parameters instead of having to be passed into a method, every time. Not a MLog() wrapper that calls a singleton to make them implicit. I personally like to define a Log() as: #ifdef DEBUG #define MYLog(fmt, ...) NSLog(@"%s: " fmt, __PRETTY_FUNCTION__, ##__VA_ARGS__) #else #define MYLog(...) #endif This way, I can log on debug builds only (add -DDEBUG as an "Other C Flag" to Xcode), and it gives me the method name that it was called on. Just enough context to be useful to track something down, not enough to cause a sea of output noise. You can use any of the C preprocessor macro's[1] this way. 1. http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/Standard-Predefined-Macros.html http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/Standard-Predefi...
- kqueue 16y agoIt can be improved, here's my version from a c program but can be used in objc in the say way. http://pastebin.com/nbgdaGXJ http://pastebin.com/nbgdaGXJ
- alecthomas 16y agoIIUC, your implementation does not solve the same problem. The OP's implementation automatically determines the correct format string from the type of the variable. So you can simply do: LOG_EXPR(some_int); LOG_EXPR(some_float); LOG_EXPR(some_complex_cocoa_type);
- deleted 16y ago[deleted]
- VMG 16y agoI have always wanted this for every programming language I had whenever I typed "printf("somelongvariable=%s", some(CTRL-P));"
- leif 16y agoWow, is the typesetting royally screwed for anyone else? See http://i.imgur.com/Doy2r.png http://i.imgur.com/Doy2r.png. Seems to happen whenever he switches to something like a code fragment or italics inline.
- pietrofmaggi 16y agoRender fine for me under OS X 10.6.4 both: - Chrome: http://emberapp.com/pietrofmaggi/images/google-chrome http://emberapp.com/pietrofmaggi/images/google-chrome - Safari: http://emberapp.com/pietrofmaggi/images/safari http://emberapp.com/pietrofmaggi/images/safari BTW: the article is not mine, I just posted it on HN.
- alextp 16y agoIt was screwed for me until I realized I was using different font sizes in my browser for proportional (13) and mono-spaced (12). Changing the size of the mono-spaced font to 13 solved it for me.