Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 657721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:51:18+00:00 2026-05-13T22:51:18+00:00

I’m getting Reaching end of non-void function warning, but don’t have anything else to

  • 0

I’m getting “Reaching end of non-void function” warning, but don’t have anything else to return for the compiler. How do I get around the warning??

I’m using customCells to display a table with 3 Sections. Each CustomCell is different, linked with another viewcontroller’s tableview within the App, and is getting its data from its individual model. Everything works great in the Simulator and Devices, but I would like to get rid of the warning that I have. It is the only one I have, and it is pending me from uploading to App Store!!

Within the - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {, I have used 3 separate If() statements-(i.e.==0,==1,==2) to control which customCells are displayed within each section throughout the tableview’s cells. Each of the customCells were created in IB, pull there data from different models, and are used with other ViewController tableViews.

At the end of the function, I don’t have a “cell” or anything else to return, because I already specified which CustomCell to return within each of the If() statements.

Because each of the CustomCells are referenced through the AppDelegate, I can not set up an empty cell at the start of the function and just set the empty cell equal to the desired CustomCell within each of the If() statements, as you can for text, labels, etc…

My question is not a matter of fixing code within the If() statements, unless it is required. My Questions is in “How to remove the warning for reaching end of non-void function-(cellForRowAtIndexPath:) when I have already returned a value for every possible case: if(section == 0); if(section == 1); and if(section == 2).

*Code-Reference: The actual file names were knocked down for simplicity, (section 0 refers to M’s, section 1 refers to D’s, and section 2 refers to B’s).

Here is a sample Layout of the code:

//CELL FOR ROW AT INDEX PATH:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

//Reference to the AppDelegate:
MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];

//Section 0:
if(indexPath.section == 0) {

    static NSString *CustomMCellIdentifier = @"CustomMCellIdentifier";

    MCustomCell *mCell = (MCustomCell *)[tableView dequeueReusableCellWithIdentifier:CustomMCellIdentifier];

    if (mCell == nil) {

        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"MCustomCell" owner:tableView options:nil];     


        for (id oneObject in nib)
            if ([oneObject isKindOfClass:[MCustomCell class]]) 
                mCell = (MCustomCell *)oneObject;
    }

    //Grab the Data for this item:
    M *mM = [appDelegate.mms objectAtIndex:indexPath.row];

    //Set the Cell
    [mCell setM:mM];

    mCell.selectionStyle =UITableViewCellSelectionStyleNone;

    mCell.root = tableView;

    return mCell;
}


//Section 1:
if(indexPath.section == 1) {

    static NSString *CustomDCellIdentifier = @"CustomDCellIdentifier";

    DCustomCell *dCell = (DCustomCell *)[tableView dequeueReusableCellWithIdentifier:CustomDaddyCellIdentifier];

    if (dCell == nil) {

        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"DCustomCell" owner:tableView options:nil];     



        for (id oneObject in nib)
            if ([oneObject isKindOfClass:[DCustomCell class]]) 
                dCell = (DCustomCell *)oneObject;
    }

    //Grab the Data for this item:
    D *dD = [appDelegate.dds objectAtIndex:indexPath.row];

    //Set the Cell
    [dCell setD:dD];

    //Turns the Cell's SelectionStyle Blue Highlighting off, but still permits the code to run!
    dCell.selectionStyle =UITableViewCellSelectionStyleNone;

    dCell.root = tableView;

    return dCell;
}


//Section 2:
if(indexPath.section == 2) {

    static NSString *CustomBCellIdentifier = @"CustomBCellIdentifier";

    BCustomCell *bCell = (BCustomCell *)[tableView dequeueReusableCellWithIdentifier:CustomBCellIdentifier];

    if (bCell == nil) {

                    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"BCustomCell" owner:tableView options:nil];     



        for (id oneObject in nib)
            if ([oneObject isKindOfClass:[BCustomCell class]]) 
                bCell = (BCustomCell *)oneObject;
    }

    //Grab the Data for this item:
    B *bB = [appDelegate.bbs objectAtIndex:indexPath.row];

    //Set the Cell
    [bCell setB:bB];

    bCell.selectionStyle =UITableViewCellSelectionStyleNone;

    bCell.root = tableView;

    return bCell;
}

//** Getting Warning "Control reaches end of non-void function" 

//Not sure what else to "return ???" all CustomCells were specified within the If() statements above for their corresponding IndexPath.Sections.

 }

Any Suggestions ??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:51:19+00:00Added an answer on May 13, 2026 at 10:51 pm

    You need a return at the End of the function, regardless of whether you’re handling the return inside of a {} block. Try:

    return nil;
    

    It’ll never get executed, but you’ll have a return for the compiler. I’d frankly redesign the statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I don't have much knowledge about the IPv6 protocol, so sorry if the question
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want to construct a data frame in an Rcpp function, but when I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.