Search code examples
xcodesynthesize

XCode 4.4 Auto @Synthesize failing on an XCode 4.3 Project


It's as simple as that.

Running Lion.

  1. I just upgraded to XCode 4.4
  2. loaded my most recent XCode 4.3 project file
  3. commented out one @synthesize line of code
  4. and errors abound. :(

Verified compiler is set to 'LLVM 4.0'.

Then I did the same test but created a new project within XCode 4.4, and voila! Auto @synthesize works within a 4.4 project.

Auto @synthesize also seems to work on new properties added to the code. But existing old one generate an error.

Anyone else experience this? Any other things I should check for?

I really want the auto generation features to work.

Thanks.


Solution

  • The Error isn't the way you declare the property but in the way that you use it.

    Auto-synthesized properties create a backing store with a leading underscore by default.

    So in your code when you have a property declared as:

    @property (nonatomic, strong) UILabel *sectorLabel;
    

    and you auto-sythesize - something like this is being auto-generated for you by the compiler:

    @synthesize sectorLabel = _sectorLabel;
    

    Now you can access it through the the property:

    self.sectorLabel;
    

    Or, you can access the backing store directly with:

    _sectorLabel;