News for hackers. Stuff that matters.
Re:Reader-submitted Objective-C / XCode tips of 2012 by orta on Monday December 31, 2012 @04:08PM (#4990891)
The LLDB View Hierarchy Dump tip is something that I think I can use again and again and again.
Re:Reader-submitted Objective-C / XCode tips of 2012 by mayoff on Monday December 31, 2012 @05:26PM (#4991148)
It wasn't clearly explained in the blog post, but that .lldbinit command should be all on one line. It creates a new command, ”rd”, that can be used in two ways.

Typing “rd” by itself does “po [[UIApp keyWindow] recursiveDescription]”, so it dumps your entire on-screen view hierarchy.

Typing “rd someview” does “po [someview recursiveDescription]”, so it dumps the view hierarchy starting at a specific view.

For Mac (Cocoa) apps, the equivalent message is _subtreeDescription, but since a window is not a view, the entire-hierarchy command needs to be “po [[[NSApp frontWindow] contentView] _subtreeDescription]”.

Re:Reader-submitted Objective-C / XCode tips of 2012 by jparishy on Monday December 31, 2012 @05:07PM (#4991092)
I mentioned this to Mattt on Twitter but I don't think he saw it. There's a lot you can do at the debugger and recursiveDescription can be called on any UIView or UIView subclass. So if you set a breakpoint you can do something like:

    (lldb) po [self.view recursiveDescription]
from one of your view controllers to dump the hierarchy of that view. This of course will work on any object that is a subclass of UIView, such as a UITableView (subclass of UIScrollView, which is in turn a subclass of UIView), a UITableViewCell (directly inherited from UIView), etc.

There's a lot of good information provided by Apple on debugging here: http://developer.apple.com/library/ios/#technotes/tn2239/

It's definitely worth the time to go through it all if you spend any time debugging iOS code (and there's a Mac OS X equivalent but I can't speak for its usefulness).

I've also started writing a little piece on debugging code with lldb and Xcode, but it's a work in progress: https://gist.github.com/3943317

Re:Reader-submitted Objective-C / XCode tips of 2012 by orta on Monday December 31, 2012 @05:14PM (#4991122)
A good accompanying video from one of the XCode devs is the video from WWDC 2012 319 - Effective Debugging with Xcode 4
Re:Reader-submitted Objective-C / XCode tips of 2012 by cozykozy on Monday December 31, 2012 @04:17PM (#4990930)
Definitely beats view.backgroundColor = [UIColor redColor];! Though I'm not sure I'll ever to shake that trusty old "debugging" hack.
Re:Reader-submitted Objective-C / XCode tips of 2012 by orta on Monday December 31, 2012 @04:22PM (#4990946)
I keep some UIColor categories around so at least I can have prettier colours for debugging. It would be nice to make a variant of the method that (somewhat randomly) colours all views and logs the usual info + the colour out to the console.
Re:Reader-submitted Objective-C / XCode tips of 2012 by tszming on Tuesday January 01, 2013 @10:38AM (#4992790)
Well, I use the same method until I heard the DCIntrospect library (https://github.com/domesticcatsoftware/DCIntrospect)
Re:Reader-submitted Objective-C / XCode tips of 2012 by MaxGabriel on Monday December 31, 2012 @04:26PM (#4990958)
It's super preliminary, but if you're debugging the problem I suspect you're debugging by looking at the view hierarchy (iOS touch handling), this might be helpful: https://github.com/MaxGabriel/debugiOSTouchHandling/blob/mas...
Re:Reader-submitted Objective-C / XCode tips of 2012 by orta on Monday December 31, 2012 @04:35PM (#4990980)
Yeah, I spotted that earlier today actually Max, I think it must have been something related to maintaining cocoapods. The library definitely has potential :)
Re:Reader-submitted Objective-C / XCode tips of 2012 by pooriaazimi on Monday December 31, 2012 @11:40PM (#4991882)
This is also interesting (many might not know about it): https://github.com/glock45/iOS-Hierarchy-Viewer