objective c - Should I declare the methods my class implements from a protcol? -


Assume that I have a purpose-class that corresponds to a protocol. In the class, I apply some methods in the protocol. Should I declare these methods in class expansion or should I save it from it?

Example

  // MyViewController.h @interface MyViewController: UIViewController & LT; UITableViewDataSource & gt; @end // MyViewController.m @ Interface MyViewController () // Should I Leave It? - (NSInteger) Table view: (UITableView *) table view numberoffer these inclusions: (NSInteger) section; @end @implementaion MyViewController - (NSInteger) TableView: (UITableView *) table view numberAffros Insight: (NSInteger) section {// implementation goes here} @end    

< Div class = "post-text" itemprop = "text">

The protocol has the necessary and optional methods. When a protocol method is optional, you should declare it in class detail or in the interface section of the class. This lets you compile the stability for you.

When implementing the necessary methods, such as tableview: numberOfRowsInSection: , you can be used on the basis of coding standards. I like to declare these methods well - either in a class extension or in the interface itself. In this way I do not need to check whether a method is needed or not.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -