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

  • Home
  • SEARCH
  • 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 7067117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:09:45+00:00 2026-05-28T05:09:45+00:00

I want to abort this method when a certain condition is not met, how

  • 0

I want to abort this method when a certain condition is not met, how should I do it?

I dont use tableView:willSelectRowAtIndexPath: method. I think it is possible to combine these two methods to prevent certain rows to be selected and be pushed into another ViewController?


EDIT:

Guys, thank you very much.

Now this code works perfectly :

- (NSIndexPath*)tableView:(UITableView *)tableView1 willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSUInteger totalcount = [totalarr count]; //totalarr is a global mutable array.

    NSIndexPath *rowToSelect = indexPath;

    if (totalcount == 0)
    {
        rowToSelect = nil;
    }
    return rowToSelect;

}
  • 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-28T05:09:46+00:00Added an answer on May 28, 2026 at 5:09 am

    tableView:willSelectRowAtIndexPath: is sent to the table view delegate when a row is about to be selected. Your delegate has the chance to change the selection, or cancel it entirely by returning an NSIndexPath object for the alternative selection, or nil to select nothing.

    Hence, if you want to inhibit the selection of certain rows, use tableView:t willSelectRowAtIndexPath:p, do your check on p, and if you don’t want that to be selected, just return nil. If you cancel the selection thus, tableView:didSelectRowAtIndexPath: will never be called.

    Don’t “cancel” things inside didXXYY type methods if you have a chance to do so in willXXYY. The did implies that the selection has been committed; UIKit might have displayed this, other event listeners might have responded, etc. It can easily lead to weird behavior.

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

Sidebar

Related Questions

First, I know about Clog , and I do not want to implement this
If certain conditions are met, I want to copy a file from one directory
Depending of some flag I want to use certain component in my mxml. There
i just want to know a general information about this particular information. Any good
How'd I go about this one? I want to tween a value from one
I already read many article about this issue in here, SO. I just want
Just a quick question about how you would go about implementing this. I want
I want to know what this looks like. I don't have any ideas about
This is what I'm talking about: http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ComboBox/ComboBox.aspx basically I want to have a drop
This is perhaps similar to previous posts, but I want to be specific about

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.