Control may reach end of non-void function error if-statement

后端 未结 5 449
[愿得一人]
[愿得一人] 2021-01-20 06:48

I\'m getting the error Control may reach end of non-void function on this code:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInte         


        
5条回答
  •  不要未来只要你来
    2021-01-20 07:34

    Midhun MP has your answer and better code style. I would strongly advice replacing all those nested else-ifs with a switch-statement as, well you don't really want else-ifs if you can avoid them...

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
           NSInteger count = 0;
           switch (changeData.selectedSegmentIndex) 
                {
               case 0:
                   count = self.tweets.count;
                   break;
               case 1:
                   count = self.tweets1.count;
                   break;
               case 2:
                   count = self.tweets2.count;
                   break;
               default:
                   break;
                }
        return count;
    }
    

提交回复
热议问题