Re: Disabling auto-synthesis of property accessors.
Re: Disabling auto-synthesis of property accessors.
- Subject: Re: Disabling auto-synthesis of property accessors.
- From: Dave <email@hidden>
- Date: Wed, 27 May 2015 13:42:09 +0100
> With regards to understanding what is going on in the 4000 line view controllers, the areas that were problematic for me were where the instance variables were declared in the interface as someProperty (or as Someproperty, ugh) and then the property was declared and manually synthesized with the same name. So, then trying to wade through the code with identical names for properties and instance variables and with cases where the variable sometimes starts with a capital letter, knowing exactly what I was looking at was not exactly straightforward.
I’ve done load of this kind of thing in the past, I’ve found the best way to handle convert iVar’s to properties is as so:
1. Refactor/Rename the iVar to the name of the property.
2. Compile - this should produce no errors, since all you have done is change the name of the iVar.
3. Add a property definition for the Property, this will error since there will be an iVar with the same name.
4. Delete or comment out the iVar.
5. Compile - there will be errors on the iVar accesses, fix as appropriate.
I’ve found it’s also better to pick a prefix for the names of iVar’s and Properties even if you get rid of the prefix once you’ve got it working, e.g.
iVar Name: mFileNameString
Property Name: pFileNameString
and if you want to synthesise it:
@synthesize pFileNameString = mFileNameString;
It’s then instantly obviously what you are working on which if you have a 4000+ line file helps a lot.
All the Best
Dave
_______________________________________________
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