Search code examples
objective-cxcodexcode4

Variable value in Xcode4


I want to watch variable [UIScreen mainScreen].brightness.

So I click rmb in watch window, select Add expression and enter [UIScreen mainScreen].brightness as my expression to watch. Xcode evaluates it but does not show the value.

How to watch it properly?


Solution

  • I don't think you can watch a property. You have to watch an instance variable. (Watchpoints actually use hardware support to monitor a memory address for changes. Properties are actually specialized syntax for a method call, and there's no memory address for the result of a method call.)

    Since you're trying to watch a property in a system class you might be out of luck. Instead, you might need to write code that adds a KVO observer for the main screen's brightness value, and set a breakpoint in the observer code.