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
5
votes
2 answers

how to center uitableview selection with indexpath value

I am saving the indexPath selection from a subview and passing it to the parent view with delegates. When I got back to my subview from my main view I pass the indexPath back to it and show the user which cell they previously selected with a tick in…
C.Johns
  • 10,185
  • 20
  • 102
  • 156
5
votes
4 answers

How to convert NSIndexPath to NSString-iOS

I want to convert NSIndexPath to NSString. How would I do it? I have to use this: - (void)restClient:(DBRestClient*)client uploadedFile:(NSString*)sourcePath { [client deletePath:@"/objc/boston_copy.jpg"]; } inside commitEditingStyle method…
Namratha
  • 16,630
  • 27
  • 90
  • 125
5
votes
2 answers

How to get the indexPath of the current cell

I have currently trying to create a way to delete an item in a collection view at the indexPath of 1 back. So far i have used some help to create a function with scrollview did scroll to create a way to count which image the user is on by the…
Nivix
  • 171
  • 1
  • 1
  • 12
5
votes
4 answers

How to add NSIndexPath to NSUserDefaults in swift

I am trying to save NSIndexPath at NSUserDefaults, but got the following exception:- Attempt to set a non-property-list object {length = 2, path = 0 - 12} as an NSUserDefaults/CFPreferences value for key LastSelectedIndeX My code:- let…
pkc456
  • 8,350
  • 38
  • 53
  • 109
5
votes
2 answers

Get indexPath of Core Data object in UITableView

I have a UITableView that I'm populating from Core Data with the following NSfetchedResultsController: - (NSFetchedResultsController *)fetchedResultsController { if (_fetchedResultsController != nil) { return _fetchedResultsController; …
Kent
  • 1,705
  • 3
  • 16
  • 26
5
votes
5 answers

Is there a way to automatically scroll to the bottom of a UICollectionView

So I'm currently working on a project that has a button that adds cells to a UICollectionView and then needs to automatically scroll to the last cell (i.e. the bottom of the UICollectionView). I've found the…
cchapman
  • 3,269
  • 10
  • 50
  • 68
5
votes
2 answers

How to add multiple NSIndexPath into NSMutableArray

I am trying to add nsindexpath into an array .. i am able to add only one indexpath .if i try to add another indexpath into array ..the debugger shows only the newest indexpath . for (int i = 0 ; i<[notificationArray count]; i++) { …
raptor
  • 291
  • 1
  • 9
  • 17
5
votes
2 answers

indexPath Value of UICollectionView

When using a UICollectionView, I am perplexed with getting the indexPath value of the didSelectItemAtIndexPath method. I'm using the following line of code in the didSelectItemAtIndexPath method: //FileList is an NSArray of files from the Documents…
Sam Spencer
  • 8,492
  • 12
  • 76
  • 133
4
votes
2 answers

Calling (deleteRowsAtIndexPaths) outside of (commitEditingStyle) in Objective-C for the iPhone

I have a custom UITableViewCell that has two custom UIButton's added to it. On one of these buttons I want to be able to delete the cell row from within myMethod(). The method is called by addTarget:@selector(myMethod:) within…
gotnull
  • 26,454
  • 22
  • 137
  • 203
4
votes
2 answers

delete section at indexPath swift

I have an array which populates a table view - myPosts. The first row of the table view is not part of the array. Each row is its own section (with its own custom footer) I am trying to perform a delete with the following code: func…
user2363025
  • 6,365
  • 19
  • 48
  • 89
4
votes
1 answer

How to access NSIndexPath section value?

I cannot understand why in the following code, indexPath.section is retuning a null value. override func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell? { NSLog("Index Path %@", indexPath) …
PassKit
  • 12,231
  • 5
  • 57
  • 75
4
votes
2 answers

Access a nested element using NSIndexPath

Is there really no API for using NSIndexPath to traverse/access a nested array construct in the iOS SDK? I've looked in the docs for both NSIndexPath and NSArray? For example: NSArray *nested = @[ @[ @[@1, @2], @[@10, @20] ], @[ …
Travis Griggs
  • 21,522
  • 19
  • 91
  • 167
4
votes
3 answers

UICollectionView reloadItemsAtIndexPaths

I've been trying to wrap my head around the reloadItemsAtIndexPaths method of UICollectionView. I have an array of objects called objectsArray. When a user scrolls to the bottom of my collection view, I fetch the next batch of objects from the…
Jdizzle Foshizzle
  • 314
  • 1
  • 3
  • 18
4
votes
1 answer

UICollectionView cellForItemAtIndexPath indexPath row is nil

First time that I'm using UICollectionView. I'm trying to get the "row" value for each cell - to be used as an identifier/tag for the cells textfield. When cellForItemAtIndexPath gets called it seems like [indexPath row]; returns nil. How can I get…
Anders
  • 2,903
  • 7
  • 58
  • 114
4
votes
1 answer

Weird behavior of UITableView method "indexPathForRowAtPoint:"

As show in the following code, when the tableview is stretched (never scrolled up), the NSLog(@"tap is not on the tableview cell") will always be called (as i thought the indexPath will always be nil). But when i tap the avatar in the section header…
lu yuan
  • 7,207
  • 9
  • 44
  • 78