有没有办法断开所有按钮touchUpInside方法? [英] Is there any way to breakpoint all the button touchUpInside method?

查看:294
本文介绍了有没有办法断开所有按钮touchUpInside方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候当你得到非常非托管代码的项目时会发生这种情况,所以你无法弄清楚如何解决一个简单的问题。在大多数情况下,调试器帮助我们从根本上开始,我只是想知道xcode调试器有多强大。因为我使用了像OllyDbg这样的asm调试器,这些为我们提供了一个号码。断点的选项我使用的最多是点击事件或点击事件的断点。那么有没有办法在xcode项目上设置一个类似的断点?

Sometime it happens when you got project with very unmanaged code so you can't figure out how to solve a simple issue. In most of the case debugger helps us to reach the root point to start with, I just want to know how strong is xcode debugger is. As I used some asm debugger like OllyDbg these provide us a no. of option to for breakpoint the most I used is breakpoint on click event or tap event. So is there any way to put a similar breakpoint on xcode project ?

推荐答案

听起来你正在寻找一种方法来捕获任何时间点击UIButton。为此,我将设置一个符号断点。在断点导航器(⌘7)中,单击屏幕底部的加号,然后选择添加符号断点

Sounds like you are looking for a way to trap any time a UIButton gets tapped. To do this, I would set a symbolic breakpoint. In the Breakpoint Navigator (⌘7), click the plus sign at the bottom of the screen and choose Add Symbolic Breakpoint

在对话框中,将以下内容添加到符号字段:

In the dialogue, add the following to the Symbol field:

-[UIControl sendAction:to:forEvent:]

这比您要求的要多一点。除了UIButton之外,它实际上会从很多东西中捕获所有事件。但是,我敢打赌,你可以让它适合你的需要。现在运行应用程序并点击一个按钮。当它到达断点时,调试器看起来与您可能习惯看到的正常堆栈跟踪略有不同,因为您将在没有源匹配符号的位置处遇到断点。使用一些命令,您可以破译相当数量的命令。例如,请参阅下面的屏幕截图。

This is a little more than you are asking for. It will actually capture all events from lots of things besides just UIButtons. However, I'll bet you can make it work for your needs. Now run the app and tap a button. When it hits the breakpoint, the debugger will look a little differently than the normal stack trace you might be used to seeing, since you will be hitting a breakpoint at a spot where you do not have source to match the symbols. With a few commands, you can decipher a fair amount. For instance, see the screenshot below.

这是我做了什么,这意味着什么。第一件事是跳过(F6)到下一个命令的开头(例如第12行),以确保输入变量的所有寄存器都被正确填充。从那里开始,我开始在寄存器中挖掘有趣的信息。在这个例子中,寄存器r15是调用对象(按钮!),r14,r12和rbx是参数(第4 - 7行)。当寄存器中的值是指向对象的指针时,您可以像在正常堆栈帧中一样打印对象。例如:

Here's what I did, and what some of this means. The first thing is to step over (F6) to the beginning of the next command (e.g. line 12), to make sure all the registers for your incoming variables are correctly populated. From there, I just start digging around in the registers for interesting information. In this example, register r15 is the calling object (the button!), and r14, r12, and rbx are the arguments (lines 4 - 7). When the value in a register is a pointer to an object, you can 'print object' it like when you are in a 'normal' stackframe. e.g.:

(lldb) register read r15
 r15 = 0x00007fc6f4a24510
(lldb) po 0x00007fc6f4a24510
<UIButton: 0x7fc6f4a24510; frame = (0 0; 414 100); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x7fc6f4a247b0>>

(lldb) po [[(UIButton *)0x00007fc6f4a24510 titleLabel] text]
Done

这篇关于有没有办法断开所有按钮touchUpInside方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆