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 8250485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:54:23+00:00 2026-06-07T23:54:23+00:00

How do I read intValue of an array of NSIndexpaths through indexPathsForVisibleRows? By the

  • 0

How do I read intValue of an array of NSIndexpaths through indexPathsForVisibleRows?

By the way, why do visibleCells and indexPathsForVisibleRows not work before if (cell == nil) function?

Here is my code:

In the cellForRowAtIndexPath method:

    static NSString *identifierString;
    UITableViewCell *cell = [tableView1 dequeueReusableCellWithIdentifier:identifierString];

    // when I use visibleCells and indexPathsForVisibleRows here, the app crashes

    if (cell == nil) 
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifierString] autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;          
    }

    // when I use visibleCells and indexPathsForVisibleRows here, the app works

//cell implementation here

    return cell;
  • 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-06-07T23:54:24+00:00Added an answer on June 7, 2026 at 11:54 pm

    (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath is where the tableview gets populated with cells. If you try to reference visible cells before they have been created, which is done within the if-statement, then the app crashes.
    The alloc command allocated memory for the cell to be created and then it gets initialized with certain parameters. This method gets called as many times as you designate in numberOfRowsInSection.

    So that you don’t recreate all the cells again and again the if-statement checks if the cell does exist and only if it is nil creates a new one to take the place.

    To get the int row value of an IndexPath you can use it’s row property. For example:

    NSArray indexArray = [self.tableView indexPathsForVisibleRows];
    int i=0;
    while(i!=indexArray.count){
       //Log out the int value for the row
       NSLog(@"%d", indexArray[i].row);
       i++;
    }
    

    Hope this helps

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

Sidebar

Related Questions

Read on before you say this is a duplicate, it's not. (as far as
Read about Server push here . I want to push data to client from
Read (skimmed enough to get coding) through Erlang Programming and Programming Erlang . One
I need to write a function that can read a file, and add all
So I read discussion about Numbers here , because I have a similar Problem.
I have values i wanted to load dynamically in an array, here are the
I want my function to return a BYTE array. The function is as follows.
I try to read pdf file. I want to use this function databuffer =
I'm pretty new to all this. I've read through the forums, but can't seem
Read about the issue in this stackoverflow question . Still have the same issue

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.