سؤال

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!

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

There is another quick solution: also add those properties in the delegate definition

    @interface YourAppDelegate : NSObject <NSApplicationDelegate> {
      NSTextField * company;
      NSSlider * company;
         ...
     }

    @property (copy) NSString   *company,
                                *address1,
                                ... ;

Disable 32-bit architecture in the build settings if you just want to release, but don't want to bother with "old" runtime limitations. (Actually what "new" runtime has finally got, was implemented in IBM SOM since 1991, so "old" and "new" are very relative when it comes to Objective-C runtime, but that's another story.)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top