You are faced with a problem in which there is no perfect solution. What you ideally have is a method that cannot be subclassed in the usual sense, available only to instances of this exact class type.
If this is a risk, it is common practice to include the class name in the installation method. So instead initialSetupyou will have something like myViewSubclassInitialSetup.
You can also add something like this at the top of your method:
NSAssert([self isMemberOfClass:[ThisClass class]],
@"IniitalSetup called by sub- or superclass")
Then your debug builds will throw an exception if a subclass or superclass ends with a call to the init method. This will give you room for a breakpoint and stacktrace, which should allow you to quickly find the problem.
It will not add any code to your versions.
Tommy source
share