综合属性和ivar错误

综合属性和ivar错误

问题描述:

我一直在以"Debug X86-64"(调试X86-64)模式(Xcode 3.6)构建程序,并且一切正常.但是,我只是尝试切换到发布X86-64"模式,并且在编译时收到了我的每个属性的以下错误:

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.

其中"x"是我的属性之一,第一个是"company"(我收到了51个此类错误).在我的.h界面文件中,我以这种方式列出了这些项目:

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.

在我的.M实现文件中,我将它们合成为:

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?

谢谢!

我相信我已经在这里回答了自己的问题.我已经做了两件事来纠正这些错误:

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

首先,我在接口文件中添加了实例变量声明.其次,我将@Synthesize指令更改为此:

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.