I'm surprised I couldn't find this in the list archives. While remodelling some old code, I got tired of scrolling and decided to replace a couple dozen old accessors with @property and @synthesize. But I inadvertantly left a few of the old getter declarations in the code. Like this one:

#import <Foundation/Foundation.h>

@interface Foo : NSObject {
    NSInteger bar ;
}

@property (assign) NSInteger bar ;

// Whoops, don't need this any more:
- (void)setBar:(NSInteger)someBar ;

@end

@implementation Foo
@synthesize bar ;
@end

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    Foo* foo = [[Foo alloc] init] ;     
    foo.bar = 600 ;
    NSLog(@"foo.bar = %d", foo.bar) ;
    [foo release] ;
    [pool drain];
    return 0;
}

Build and run the above project. No warnings, no errors, no exceptions, but the output logs:

   JunkProps[7449:10b] foo.bar = 0

Remove the old getter declaration under // Whoops, and it's fixed:

   JunkProps[7462:10b] foo.bar = 600

If I change 'bar' to be an NSString* instead of an NSInteger, the extra setter does not cause this problem.

I cannot think of any sensible explanation for this.

Jerry



_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to