Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar?
Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar?
- Subject: Stupid Cocoa question. How can you tell if the object you are looking at is a property or an ivar?
- From: Alex Zavatone <email@hidden>
- Date: Wed, 20 May 2015 16:04:52 -0400
In the code I've inherited, I've got the benefit of spending some time refactoring and have an interesting situation.
Many times in the classes, an ivar is defined in the @interface of the class. Sometimes not. Then sometimes, the same name of the ivar is used in the class and defined as a property and @synthesized.
Sometimes not.
Sometimes, the ivars and properties start with lowercase letters as intended. Sometimes not.
Now, I remember back in 2012 that I could access a property within an instance of the object without using self, but never knew if I was accessing the ivar or the property itself simply by looking at the object.
Sure, if there was a 'self.' in front of the object instance, I knew it was the property. But in the case(s) I have today, I'm looking at inconsistently cased instance variables (some properties) and nowhere are any preceded by 'self.' within the object instance, yet in the debugger's variable pane, these variables that look like ivars are all under listed under self.
Wha?
Which are they, ivars or properties?
I don't know. I can't tell.
Is there any way to inspect an instance and tell if it is a property or an ivar if both the property and ivar have the same name?
Fun times, fun times.
Thanks in advance.
- Alex Zavatone
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden