1

I'm having a strange error when trying to override the setter and getter of a property.

On my header file I've defined the following property:

@property (strong, nonatomic) NSDate *startedOn;

On the implementation, I have this setter:

- (NSDate *)startedOn {
    if (!_startedOn) {
        [self updateStartedOn];
    }

    return _startedOn;
} 

Everything is working as it should at this point, but, when I try to override the setter like this:

- (void)setStartedOn:(NSDate *)startedOn {
    _startedOn = startedOn;
}

I get the following error:

enter image description here

This doesn't make any sense to me, what I've checked:

  • The setter nor getter have any duplicated definition
  • The parent class doesn't have any duplicated definition
  • None of the class's categories have any duplicated definition

Does any one have a clue of what I'm doing wrong? Thanks.

Fantini
  • 2,067
  • 21
  • 32
  • You can also read more here http://stackoverflow.com/questions/13817562/property-not-working-with-getter-and-setter and http://stackoverflow.com/questions/24638826/xcode-6-how-to-fix-use-of-undeclared-identifier-for-automatic-property-synthes there are many more threads about this. Make sure you search before creating a new :) GL –  Mar 28 '17 at 21:56

1 Answers1

1

Try to put in the implementation file;

@synthesize startedOn = _startedOn;
fjtrujy
  • 129
  • 4