UIView のデバッグに便利な recursiveDescription を Swift で使う

  • 10
    Like
  • 1
    Comment
More than 1 year has passed since last update.

recursiveDescription メソッドはビューの階層構造をダンプできてデバッグに便利です。
プライベートメソッドなので performSelector を使います。

(lldb) po self.contentView.performSelector("recursiveDescription")
▿ Unmanaged<AnyObject>
  - _value : <UIButton: 0x7ff21159abe0; frame = (0 0; 60 60); alpha = 0; opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x7ff211599f80>>
   | <UIButtonLabel: 0x7ff21159b540; frame = (0 0; 0 0); hidden = YES; opaque = NO; userInteractionEnabled = NO; layer = <_UILabelLayer: 0x7ff21159bb90>>

Objective-C と同じでいけると思ったら ダメでした。

(lldb) po self.contentView.recursiveDescription()
error: <EXPR>:1:1: error: value of type '$__lldb_context' has no member 'recursiveDescription'