I am developing a simple set of reusable code. I have created a protocol to group a set of methods and ask the user at run time for data.
I think that setting a delegate would be mandatory. Can I force the developer at runtime to set the delegate by throwing an assert stating the reason?
Is this a good practice to enforce the user of my classes by using asserts? Does it have a design level flaw?
First the “good practice” question:
Don’t make methods optional if they aren’t.
Not a critical one, more of an opinion
initWithDelegate:if a delegate is requiredinitmethod, I’m made aware of it earlier.You can cause warnings at compile time by simply adding the
@requiredindicator to your protocol:You can still cause runtime asserts with: