cocoaivarsynthesize

Synthesized Properties and ivar error


I've been building my program in the "Debug X86-64" mode (Xcode 3.6) and everything works flawlessly. However, I just tried switching to "Release X86-64" mode and upon compiling received the following errors for each of my properties:

Synthesized property 'x' must either be named the same as a compatible ivar or must
explicitly name an ivar.

Where 'x' is one of my properties, the first being 'company' (I received 51 errors of this type.). In my .h interface file, I've listed the items this way:

@property (copy) NSString   *company,
                        *address1,
                        *address2,
                        *city,
                        *usState,
                        *zip,
                        *phone,
                        *fax,
                        *email,
                        *web; // etc, etc.

In my .M implementation file, I've synthesized them as so:

@synthesize company,
        address1,
        address2,
        city,
        usState,
        zip,
        phone,
        fax,
        email,
        web; // etc, etc.

My understanding was that the instance variables are automatically created for these properties... in fact, they seem to be working perfectly, up until I try to compile in "release" mode.

I couldn't find anything in the books I have to explain this. Am I doing something wrong, or more specifically, what should I include to fix this for "release" compiles?

Thanks!


Solution

  • I believe I have answered my own question here. I have done two things to correct these errors:

    First, I've added instance variable declarations in the interface file. Second, I changed the @Synthesize directives to this:

    @synthesize company = company;
    @synthesize address1 = address1;
    etc...
    

    This has fixed all of the errors and everything compiles correctly in both build and release modes.