RubyMotionのREPL便利ですよね。そう、あのirb的なやつです。
シミュレーターでCommand+Clickでクリックしたところで色々な変数やメソッド見られるのはいいんですが、実際思っているクラス(ViewControllerとか)にいかなくて苦労したりしませんか?
そんな時はREPLで以下のコマンドを打ってAppDelegateからたどっちゃいましょう!
app = UIApplication.sharedApplication
repl app.delegate
実際にはこんな感じで使います。
TabBarViewの、1つ目のタブにあるボタンで、'target'という文字列を含むメソッドを探す例。
$ rake
Build ./build/iPhoneSimulator-6.1-Development
Simulate ./build/iPhoneSimulator-6.1-Development/Sample.app
(main)> app = UIApplication.sharedApplication
=> #<UIApplication:0x9475190>
(main)> app.delegate
=> #<AppDelegate:0x76711c0 @window=#<UIWindow:0x76aa640>>
(main)> repl app.delegate
=> #<AppDelegate:0x76711c0 @window=#<UIWindow:0x76aa640>>
(#<AppDelegate:0x76711c0 @windo...)> @window
=> #<UIWindow:0x76aa640>
(#<AppDelegate:0x76711c0 @windo...)> @window.rootViewController
=> #<UITabBarController:0xd174850>
(#<AppDelegate:0x76711c0 @windo...)> @window.rootViewController.viewControllers
=> [#<TagBasedIBViewController:0xd174590>]
(#<AppDelegate:0x76711c0 @windo...)> @window.rootViewController.viewControllers[0]
=> #<TagBasedIBViewController:0xd174590>
(#<AppDelegate:0x76711c0 @windo...)> repl @window.rootViewController.viewControllers[0]
=> #<TagBasedIBViewController:0xd174590>
(#<TagBasedIBViewController:0xd...)> @button
=> #<UIRoundedRectButton:0x96871c0>
(#<TagBasedIBViewController:0xd...)> @button.methods.grep /target/i
=> [:"addTarget:action:forControlEvents:", :"removeTarget:action:forControlEvents:", :"actionsForTarget:forControlEvent:", :"sendAction:toTarget:forEvent:", :hasOneOrMoreTargets, :"addTarget:action:forEvents:", :allTargets, :"removeTarget:forEvents:", :"forwardingTargetForSelector:"]