I'm creating a custom subclass of UIView. I'm currently doing initialization based on Objective C - Custom view and implementing init method?, so that there's some initialization that gets done whether loading from code or from a xib.
The problem I have now is that I am adding a property that is 'required' (let's call it reqProp for discussion's sake) - the view can't render without this property being set, and it must be set before any other functionality specific to my view subclass can be used.
Because of this, I figured the natural place to enforce this requirement would be to provide a new init function, so I don't have to worry about it not being set throughout the rest of my code - for example
initWithFrame:(CGRect)frame forReqProp:(NSString *)reqProp;
However, I'm not sure how to enforce the same requirement when initializing through initWithCoder.
The closest I can think of is to require specifying this property in User Defined Runtime Attributes (right under where the Custom Class name would need to be defined in interface builder), but in that case, it's not clear when/if I should "blow up" because of the property not being specified.
The only other option I can think of is just have very explicit documentation that this required property must be the first thing set before using the view.