fbrereto
fbrereto

Reputation: 35935

Debugging iOS: How do I break on property value change?

I am trying to find out how a UIViews transformation matrix is being modified. Thus (using the gdb console) I'd like to watch for any/all changes of the UIView's transform property. How would I go about doing so?

Upvotes: 21

Views: 6041

Answers (3)

Xavier Chia
Xavier Chia

Reputation: 257

If you're like me, and don't write in Obj-C, here's a quick Swift way to do it for beginners.

enter image description here

Just add a didSet to the property, and a breakpoint inside the block.

Upvotes: 0

Leszek Szary
Leszek Szary

Reputation: 10346

Use a symbolic breakpoint -[UIView setTransform:]. Note that you can also use a condition with $arg1 (works only on 64bit simulator like iphone 5s) compared to some pointer to catch breakpoints on property change only for a specific instance $arg1 == 0x7f9cbba75e60. Screenshot below shows a breakpoint that catches changes on transform property only for UIView instance that has a pointer 0x7f9cbba75e60

xcode symbolic breakpoint

Upvotes: 13

PeyloW
PeyloW

Reputation: 36752

Add a symbolic breakpoint in Xcode. Use -[UIView setTransform:] as the Symbol.

Use a more narrow subclass class if you want less or more specific output.

Upvotes: 30

Related Questions