This test will fail:
#import 'GTMSenTestCase.h' @interface Person : NSObject @property (readonly) NSString *name; @end @implementation Person - (NSString *)name { return @'Nick'; } @end @interface TemplateUnitTest : GTMTestCase @end @implementation TemplateUnitTest static BOOL called = NO; - (Person *)get { if (called) { STFail(nil); } called = YES; return [[Person new] autorelease]; } - (void)testPropertyMakesThingGetSentTwice { NSString *s = [[self get].name stringByAppendingString:@'foo']; STAssertEqualObjects(@'Nickfoo', s, nil); } @end
If I replace the [self get].name with [[self get] name], it passes. ie, Using dot-syntax, the LHS of the ‘.’ is evaluated twice. How does this happen?
Admitting in public that you use the dot syntax in Objective-C is likely to get you burned at the stake by the purists 😉
It looks like it’s a bug in this particular scenario, as the thread says, it’s probably some pre-processing magic that’s expanding it wrongly.