bits about life, coding and stuff
It’s safer, less code and more flexible. Old Code: – (void)setSelectedUnit:(FZUnit *)unit { if (selectedUnit == unit) { return; } RELEASE(selectedUnit); selectedUnit = [unit retain]; [self updateButtonArea:unit]; } New: // add notification when selected unit changes __block __typeof__(self) blockSelf; = self;[self addObserverForKeyPath:@"selectedUnit" task:^(id obj, NSDictionary *change) [...]
Just found that on Twitter – and since it’s just THAT awesome to know how to fix “Cancelling call as the malloc lock is held so it isn’t safe to call the runtime” or “warning: Not safe to look up objc runtime data”. – i’ll reblog it. Thanks to Fat Cat Software. First, I need [...]
For our one year cocoaheads meeting at vienna’s metalab i gave two lightning taks about some new awesome frameworks I use: Hockey for AdHoc updating and Lumberjack for better logging. If you are an iOS or Mac developer around vienna, feel free to come at our next metting! (checkout cocoaheads.at for dates) Here are the [...]
I guess until now nearly EVERY block i wrote created a retain cycle. Bummer. But if you think about it, it’s obvious. Most calls in a block use self. This gets retained, and your retain cycle is perfect. But at least for blocks, the solution is quite simple: __block __typeof__(self) blockSelf = self; [...]
Want awesomely fast and flexible logging in your iOS/Cocoa apps? Don’t use NSLog! Use cocoalumberjack. I’ve written an custom formatter to make it even more awesome. It will give you output like this: 2010-09-09 15:38:58:125(207) [AppDelegate application:didFinishLaunchingWithOptions:/59] app is starting up… Look again. You get: Log Level (Info is omitted, can be Verbose, Warn, Error) Exact [...]