ivars allowed in Cocoa Touch-based anonymous category but not in "regular" Cocoa?

Go To StackoverFlow.com

1

I noticed two things when switching between iOS and regular OS X development:

//SomeClass.h
@interface SomeClass: SomeUIClass

    @property (retain)SomeProperty* someProperty;

@end

//SomeClass.m
@interface SomeClass ()
{
    SomePrivateVar* somePrivateVar;
}
@end

@implementation SomeClass

@synthesize someProperty;
@end

The above will compile just fine under iOS. That is:

  1. I can synthesize the property without declaring an ivar explicitly in the public @interface
  2. I can further declare other private ivars in the .m file under the anonymous category (class extension).

However, if compiling for OS X and subclassing some NS-based class as opposed to a UI-based one (say, NSView instead of UIView), both the above things result in compiler errors.

I guess I thought Objective-C 2. allowed for the above in general, but they are only "shortcuts" in iOS? or what's the deal with them being allowed in iOS but not in OS X?

2012-04-04 23:58
by SaldaVonSchwartz


2

Those are features of the "modern runtime" which can only be used for 64 bit apps on Mac OS X. You're probably building a universal binary that also includes a 32 bit version.

2012-04-05 00:13
by omz
Oh.... aha. Yep, actually I'm building universal 32/64 and as a matter of fact, have to end up compiling in 32 anyway cause for some reason auval (the audio unit validation tool -- I'm building an audio unit plugin) doesn't even see the built component if it's built under 64-bit - SaldaVonSchwartz 2012-04-05 00:20
Ads