Adding _weak results in error


#1

In the Weak References section when I add _weak to the Employee *holder; ivar declaration to fix the retain cycle I get an error "Parse Issue - Unknown type name _weak.

Running Xcode 4.2.

Is there a build setting that allows _weak to be used. I looked but can’t find anything.

I am also running into this in Chapter 24, Callbacks where it is indicated to use “_unused” to suppress the warning that the *timer variable is not used. When I prepend “_unused” to the: NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:logger selector:@selector(sayOuch:) userInfo:nil repeats:YES]; statement, I get a hard “User of undeclared identifier ‘_unused’”.

The fact of these two (to me) similar issues leads me to believe that there is some configuration or build parameter (compiler settings?) that isn’t set correctly in my installation of Xcode.


#2

It is two underscores:


#3

Understood now. I’m reading the Kindle version and it shows up with no break between the two characters.

Thanks for the correction.


#4

This actually does seem to result in an error for me.

Asset.h

@interface Asset : NSObject { __weak Employee * holder; ... } @property (weak) Employee * holder; ... @end

Asset.m

...
@synthesize holder;
...

gives me the following error:
existing ivar holder for strong property holder may not be __weak


#5

Compiles OK on my end here. Can you post the complete file contents?