So a pretty big thread has busted open on the Apple Developer Forums on “Why use instance variables if you have properties?

I thought the answer to this was pretty simple: if you rely on synthesized private instance variables, you can’t see their values when debugging! So as far as I understand, if you do synthesize properties, you had better have instance variables if you ever want to see them in the debugger.

The length and flamey-ness of the thread leads me to believe this isn’t a big enough deal. Am I missing something?

2 Responses to “Nerd Fight: Why use instance variables if you have properties?”  

  1. 1 Tom Harrington

    You can see private synthesized ivars while debugging, only you have to call the synthesized accessor in order to do so. So in GDB, rather than use “po foo” you’d use “po [self foo]”. That works fine unless you’ve provided your own getter and have a breakpoint in it. Then, things kind of fall apart since GDB hits the breakpoint while trying to call the method.

  2. 2 am

    I have to admit that my main motivation in posting this was to see if there was a way to view synthesized instance variables, since I suspected that there was. Thanks for clearing this up!

Leave a Reply