iphone - When programming iOS ViewControllers should you call parent class methods before or after your own code? -
There are several "boilerplate" methods in a new IOS ViewControllers created from a template that call their parental class methods .
- (zero) viewDidoadload {[Super Viewedload]; } - (zero) viewDidUutup {[SuperWooddownload]; } - (zero) Delok [[Super Delooc]]; }
While modifying these sections, should I keep my own code before or after the parents class call?
- (zero) viewDidoadload {// I put my code here? [Super viewedload]; // or here? }
This is generally applicable to OOP in general. In the constructor (and in other ways also) you should call the parent's constructor before your code. The reason is that your code may have some preliminary requirements which are handled in the parent, i.e. should be preceded by the initially generated class of origin, before the commencement of the class. In the Destroyer you should contradict, i.e., issuing resources of the derived class should go before releasing the resources of the base. The reason may be directly dependent on the source of the resource base of the derived class. If you release the resources of the base, then there may be a problem before
this is the ideal case. In many cases you do not make any difference, but if there is dependency like above dependence then you will be in trouble. So you should follow the standard code, the method of base code should be contrasted with your code before and in Delok.
Comments
Post a Comment