Overrides the synhesize property in Objectice-C Ok or bad?

I redefined the synthesized property because I wanted to add NSAssert.

Is it okay to do this (for example, override) or consider it a bad practice?

@synthesize someField;

-(NSString*)someField {
    NSAssert(someField != nil,@"someField");
    return someField;
}

thanks

+5
source share
1 answer

It's fine. From the documentation :

You use the @synthesize keyword to tell the compiler that it should synthesize the setter and / or getter methods for the property if you do not supply them in the @implementation block.

So, if you provide them, then the compiler will use yours, regardless of the @synthesize directive.

+5
source

All Articles