Cómo obtener parámetros usando puntos de interrupción simbólicos en Objective-C
Tengo un punto de interrupción que se parece a esto
-[UITableViewCell setSelected:]
Y funciona, pero no puedo averiguar cómo obtener el valor que se está pasando.
He intentado -[UITableViewCell setSelected:(BOOL)what]
y -[UITableViewCell setSelected:what]
que no funcionan en absoluto.
¿Cómo puedo acceder a los parámetros?
Si esto no funciona, voy a tener que hacer un DebugUITableViewCell
solo para ver lo que está pasando, que es una molestia y toca una gran cantidad de código.
3 answers
Si depura su código en el dispositivo, los parámetros cuando llegue a su punto de interrupción estarán consistentemente en los registros r0, r1 y r2. Si se uso po $r0
verás el objeto de recibir setSelected. Si usas po $r1
obtendrás "no Objective-C description available" porque ese es el selector. Inspeccione $r2 para ver si selected está configurado en SÍ o NO. Es una historia similar en i386, pero no puedo recordar de mano qué registros se utilizan.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-03-20 01:04:25
En LLDB en el uso del simulador
p $arg3
Para el primer parámetro.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-06-12 19:09:53
Podría reemplazar -[UITableViewCell setSelected:]
con su propia implementación para fines de depuración. A continuación, UITableViewCellSetSelected
se llamará en lugar del método de UIKit.
static void (*__originalUITableViewCellSetSelected)( UITableViewCell *, SEL, BOOL ) ;
static void UITableViewCellSetSelected( UITableViewCell * self, SEL _cmd, BOOL b )
{
// your code here... (or set a breakpoint here)
NSLog(@"%@<%p> b=%s\n", [ self class ], self, b ? "YES" : "NO" ) ;
(*__originalUITableViewCellSetSelected)( self, _cmd, b ) ; // call original implementation:
}
@implementation UITableViewCell (DebugIt)
+(void)load
{
Method m = class_getInstanceMethod( [ self class ], @selector( setSelected: ) ) ;
__originalUITableViewCellSetSelected = (void(*)(id, SEL, BOOL))method_getImplementation( m ) ;
method_setImplementation( m, (IMP)UITableViewCellSetSelected ) ;
}
@end
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-03-20 01:13:41