Questions tagged [nsindexpath]

The NSIndexPath class represents the path to a specific node in a tree of nested array collections in Objective-C. This path is known as an index path.

Each index in an index path represents the index into an array of children from one node in the tree to another, deeper, node. For example, the index path 1.4.3.2 specifies the path shown below:

enter image description here

iOS adds programming interfaces to the NSIndexPath class of the Foundation framework to facilitate the identification of rows and sections in UITableView objects. The API consists of a class method and two properties. The indexPathForRow:inSection: method creates an NSIndexPath object from row and section index numbers. The properties return the row index number and the section index number from such objects

Resource

509 questions
8
votes
4 answers

How to detect scrolling to a new section in a UICollectionView?

I am implementing an infinite-scrolling calendar. My issue is that I would like to set the current month as the title in the navigation bar and it should update while scrolling - once you pass the section header view the title should update in the…
8
votes
2 answers

iOS 7 beginUpdates endUpdates inconsistent

Edit: The solution for this answer is related to iOS7 sometimes returning NSIndexPath and other times returning NSMutableIndexPath. The issue wasn't really related to begin/endUpdates, but hopefully the solution will help some others. All - I'm…
coder
  • 10,460
  • 17
  • 72
  • 125
7
votes
4 answers

Return NSIndexPath from custom cell ? (UITableView)

I need to get the NSIndexPath for a custom cell in a UITableView. Here's the problem: I send a NSNotification from my custom cell to my UITableViewController when editingDidBegin gets called from a UITextField in my custom cell. In my…
JonasG
  • 9,274
  • 12
  • 59
  • 88
7
votes
1 answer

How do I get specific values from a NSIndexPath

I have a NSArray with NSIndexPaths inside of it NSArray *array = [self.tableView indexPathsForSelectedRows]; for (int i = 0; i < [array count]; i++) { NSLog(@"%@",[array objectAtIndex:i]); } The NSLog returns this: 2…
Heli0s
  • 119
  • 1
  • 1
  • 7
7
votes
3 answers

tableView.cellForRowAtIndexPath(indexPath) return nil

I got a validation function that loop through my table view, the problem is that it return nil cell at some point. for var section = 0; section < self.tableView.numberOfSections(); ++section { for var row = 0; row <…
Incognito
  • 493
  • 2
  • 8
  • 22
7
votes
4 answers

indexpath.row is starting from 1 instead of 0

i am facing a strance issue with a uitableview. sometime when my table's datasource/numberofrowsinsection has 3 values, cellforowatindexpath starts from 0-1 instead of 0-0. can someone help me out finding the possible reasons for this issue to…
ravoorinandan
  • 783
  • 2
  • 10
  • 26
6
votes
1 answer

Assertion Failure for UITableView selectRowAtIndexPath

I feel like this is an issue that requires special attention... my Google-fu is pretty good but I haven't been able to get anything useful. This is the simplest thing, and yet I can't seem to figure out what the problem is with it. I have a…
Liandri
  • 313
  • 1
  • 3
  • 8
6
votes
4 answers

How to increment an NSIndexPath

I have a data situation where I want to use an index path. As I'm traversing the data I want to increment the last node of an NSIndexPath. The code I have so far is: int nbrIndex = [indexPath length]; NSUInteger *indexArray = (NSUInteger…
drekka
  • 20,957
  • 14
  • 79
  • 135
6
votes
5 answers

How to get indexPath in a tableview from a button action in a cell?

I have a tableview with two actions in it, for the first on i use the delegate didSelectRowAtIndexPath, for the second one i would like to use an action on a button on my cell to do something else. My problem is that i don't succeed to get the…
Sylvain Bessot
  • 181
  • 1
  • 3
  • 13
6
votes
1 answer

Get the indexPath of cell in the center of collectionView in swift?

I have tried this to get the index of a cell in the center of a collection view by using an extension of uicollectionview, but I always get nil instead of the index. How can I fix this? extension UICollectionView { var centerPoint : CGPoint { …
eeschimosu
  • 633
  • 2
  • 10
  • 24
6
votes
4 answers

Get current indexPath row with multiple sections?

I have a UITableView with multiple sections. Instead of the typical approach of using an array per section, I am using one array. Anyway, I am having trouble getting the current indexPath.row as if there was only one section in the tableview. So…
user3251233
  • 135
  • 2
  • 5
6
votes
2 answers

UITableView's indexPathForCell: returns always 0 as indexPath.row

I have a UITableView with custom cells in it. This custom cell looks like a normal cell with Style "Detail Left". But my custom cell has a detail label and a text field, to allow the user to edit the text. I have a Save button where I want to save…
tester
  • 3,977
  • 5
  • 39
  • 59
5
votes
3 answers

UITableView indexPath section logic

This is the abridged code for my cellForRowAtIndexPath UITableView delegate method: - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView…
eric.mitchell
  • 8,817
  • 12
  • 54
  • 92
5
votes
2 answers

How to reset the tableview cells accessorytype to none on a click of a button?

I am trying to code a reset button, so that when I click on that button all the tableview cells' accessory type get set to none. I have a clear concept of how to do it, but I am pretty new to iPhone development so I just need help with what methods…
subodhbahl
  • 415
  • 9
  • 22
5
votes
1 answer

iOS5: How to prevent exception for rectForRowAtIndexPath method

Exception: request for rect at invalid index path Code: CGRect rect = [tableView rectForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]]; Fix: if ([tableView numberOfRowsInSection:0] <= i) { return; } Maybe exist the better way
Alex Sfinx87
  • 244
  • 5
  • 16