tags:

views:

147

answers:

1

I have overridden a synthesized property because I wanted to add an NSAssert.

Is this OK to do (i.e override) or considered bad practice?

@synthesize someField;

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

Thanks

+3  A: 

That is 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 within the @implementation block.

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

Peter N Lewis