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
21
votes
3 answers

Get the IndexPath from inside a UITableViewCell subclass in Swift

I have a custom UITableViewCell subclass and its associated xib. I have a UILabel and a UIButton in this cell and I have wired the touch up inside action of the button to the subclass. What I need is when that button in the cell is tapped, to get…
Isuru
  • 30,617
  • 60
  • 187
  • 303
21
votes
13 answers

how to access from UICollectionViewCell the indexPath of the Cell in UICollectionView

i want to animate the UICollectionViewCell when action is called. i have done UICollectionViewCell in Interface Builder, the UICollectionView also. Now i want to get the correct indexPath at my actionBtnAddToCard method. thats the way i try it now…
brush51
  • 5,691
  • 6
  • 39
  • 73
20
votes
3 answers

How to convert int to nsindexpath?

I am making a basic quiz application.The choices are in the form of a table view. If the user moves to a previous question, I want to show him his previously selected choice. I have stored the choice in NSUserDefaults. How do I convert this int…
Adam Young
  • 1,321
  • 4
  • 20
  • 36
19
votes
7 answers

Get last cell in a UITableview section

I have a section in UITableView which has multiple rows. I wish to get the last row or the last cell of the section to add a disclosure indicator on it. One way I am thinking to use is: NSIndexPath *lastCellIndexPath = [NSIndexPath…
tech_human
  • 6,592
  • 16
  • 65
  • 107
18
votes
5 answers

How to get a selected item in collection view using indexPathsForSelectedItems

I have a collectionView of photos and want to pass the photo who was cliked to a detailViewControler. The collection data come from : var timeLineData:NSMutableArray = NSMutableArray () I would like to use the prepare for segue method. My problem…
jmcastel
  • 1,365
  • 7
  • 17
  • 34
17
votes
3 answers

switch that checks NSIndexPath's row and section

I would like to set a switch statement that checks for a value if NSIndexPath. NSIndexPath is a class and it consists(among other things) of section and row (indexPath.row, indexPath.section) this is how I would formulate an if statement to check…
potato
  • 4,479
  • 7
  • 42
  • 99
17
votes
4 answers

UITableView Cell IndexPath

Can anyone tell me how can I get a cell IndexPath? I was saving the IndexPath in the tableView: cellForRowAtIndexPath: method but this only loads when the cell is viewed and I need to know its index path on the viewDidLoad method. this resulted in a…
Leonardo Marques
  • 3,721
  • 7
  • 36
  • 50
16
votes
2 answers

Is NSIndexPath threadsafe?

Apple's multithreading docs don't list NSIndexPath as threadsafe or not! As an immutable class, I'd generally expect it to be threadsafe. Previously, I'm sure the documentation used to state that NSIndexPath instances were shared and globally…
Mike Abdullah
  • 14,933
  • 2
  • 50
  • 75
15
votes
3 answers

tableView:cellForRowAtIndexPath called with nil indexPath after deleting item

I have a rather vanilla UITableView managed by an NSFetchedResultsController to display all instances of a given Core Data entity. When the user deletes an entry in the table view by swiping over it, tableView:cellForRowAtIndexPath: eventually gets…
Jean-Denis Muys
  • 6,772
  • 7
  • 45
  • 71
15
votes
1 answer

Objective-C: Instance Variable in Category

I am just asking whether it was possible to add an instance variable via a category. My special problem is, that I need to add an NSIndexPath property to an ASIHTTPRequest object but I don't wanna subclass the ASIHTTPRequest as a matter of…
cschwarz
  • 1,195
  • 11
  • 24
15
votes
2 answers

NSFetchedResultsController prepend a row or section

I have a UITableView populated with a standard NSFetchedResultsController. However I'd like to prepend a row or a section (row preferably but either would works fine really.) The only way I can possibly see doing this right now is to rewrite all the…
Philip
  • 769
  • 7
  • 20
14
votes
7 answers

Check whether cell at indexPath is visible on screen UICollectionView

I have a CollectionView which displays images to the user. I download these in the background, and when the download is complete I call the following func to update the collectionViewCell and display the image. func…
Alk
  • 5,215
  • 8
  • 47
  • 116
13
votes
3 answers

Set NSIndexPath programmatically

My question is: How to set NSIndexPath programmatically. For example I add method: - (void)setDefaultValue{ tempIndexPath = [NSIndexPath indexPathForRow:0 inSection:1]; } In tableView delegate -cellForRowAtIndexPath I want to compare two…
Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
13
votes
4 answers

error with scrollToRowAtIndexPath

I am getting an error when using my application that used tableviews, the error looks like this. 2012-01-19 10:19:51.442 bcode[1176:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[UITableView…
C.Johns
  • 10,185
  • 20
  • 102
  • 156
13
votes
5 answers

iOS UITableView Scroll to bottom of section

I am going to make a tableview with 2 sections inside it. I can add cells to every section programmatically and when i add, i scroll to the end of tableview using [_tableView setContentOffset:CGPointMake(0, CGFLOAT_MAX)]; My question is how can i…
Mostafa A. Khattab
  • 167
  • 1
  • 1
  • 8
1
2
3
33 34