Home > iphone > How to get all indexPaths from a UITableView?

How to get all indexPaths from a UITableView?

I find this a very basic question, but somewhat difficult to find in the Apple documentation. The answer is not found in the NSIndexPath Class Reference, but in the NSIndexPath UIKit Additions. That’s why I think some people would not know about the following method which allows us to get a specified indexPath from a UITableView.

The method is:

+ (NSIndexPath *)indexPathForRow:(NSUInteger)row inSection:(NSUInteger)section

And it returns an indexPath object initialized with the indexes of a specific row and section in a table view.

With this method we will be able to retrieve all the indexPaths from a table view performing a loop like this:

NSInteger nSections = [tableView numberOfSections];
for (int j=0; j<nSections; j++) {
  NSInteger nRows = [tableView numberOfRowsInSection:j];
  for (int i=0; i<nRows; i++) {
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:j];
    //Do something with your indexPath. Maybe you want to get your cell,
    // like this:
    //UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

I hope this helps. If you find an easier way, please tell me.

  • Facebook
  • Twitter
  • Google Plus
  • Meneame
  • Add to favorites
  • RSS
  • BarraPunto
Categories: iphone Tags:
  1. elbolsa
    May 28th, 2009 at 09:07 | #1

    yes, i have always asked myself about this subject. thank you very much!!

  2. Metodij Zdravkin
    May 17th, 2011 at 07:57 | #2

    Excellent post… been searching google for this and there is not a single other post that answers this question.


    cell.accessoryType = UITableViewCellAccessoryNone;

    in the last for cycle and got a custom check view.

    Thanks a lot!!!

  3. Faris
    September 30th, 2015 at 03:03 | #3

    NSArray *indexPaths = [self.tableView indexPathsForVisibleRows];

  1. No trackbacks yet.

four × = 8

, lititz, pa 17543 notice of privacy practices | privacy policy | terms of use medical services bariatric services cardiac care network emergency medicine center labor delivery center regional center for cancer care robotic surgery center wound healing see all services raquo treatments procedures breast imaging ct scan mri x-ray patients find a doctor pay my bill before you arrive when you arrive going home registration billing faq insurance payment information patient bill of rights and responsibilities virtual tours medical records request visitors visitor information local accomodations gift shop patients visitors maps directions events childbirth education programs community lectures health well-being senior services special events weight loss surgery seminars programs cuddlebugs working on wellness assessments health assessments health topics healthy living health centers family health see all health topics raquo interactive tools blood pressure quiz bmi calculator calorie burn rate calculator diabetes quiz target heart rate calculator health library a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z for patients find a doctor for physicians physician opportunities graduate medical education physician spotlight hugh, ann marie surgery see full bio raquo hospitals heart of lancaster regional medical center family health clinics baron family practice center city family health heartland family health highlands family health center lancaster family practice associates quarryville family medicine sallavanti cotter family medicine affiliated hospitals lancaster regional medical center - an affiliate of heart of lancaster regional medical center other locations bariatric and metabolic institute of lancaster breast health associates community surgical associates obgyn of lancaster pequea valley internal medicine the women's place at heart of lancaster regional medical center the wound healing center of heart of lancaster our story leadership mission and vision phone directory joint commission/accreditation commitment to our community careers why heart of lancaster? nursing at heart of lancaster benefits physician opportunities hospital opportunities volunteer opportunities news news releases. Uterine leiomyosarcoma leiomyosarcoma may arise in a previously existing benign leiomyoma (sarcomatous transformation) or independently from the smooth muscle cells of the myometrium. http://louisianaherps.com/wmr-52465/ extremetack.ca/ajy-54139/ See additional information.. As estrogen levels tend to increase before menopause starts, many uterine fibroids start to grow. vardhmancars.com/vys-58648/ They range widely in how invasive they are. As estrogen levels tend to increase before menopause starts, many uterine fibroids start to grow. Medicinenet. clabacoons.it/docz/eski.php?goa=59253 irishceremonies.ie/tfg-59140/ Consider the 24 hour cleanse in linda page's bestselling book, healthy healing 12th edition: a guide to self-healing for everyone. elementalmanhattan.org/lyz-57563/ Chandler regional: saturday, november 13 th beginning at 12:30 p. If you have any of these symptoms do not assume it is due to fibroids. does viagra work for women yahoo Comment:Acircnbsp s. Medicinenet. Next, the surgeon makes an incision over each fibroid, grasping and pulling out each growth. women viagra use women The embolization cuts off the blood supply to the fibroids, thus shrinking them. pongola-advertiser.co.za/slider/data1/tooltips/catched.php?wfm=51115 Or view hourly updated newsfeeds in your rss reader: email newsletters rss newsfeeds feedback... viagra quotes funny