Questions tagged [nsindexset]

The NSIndexSet class represents an immutable collection of unique unsigned integers, known as indexes because of the way they are used. This collection is referred to as an index set. You use index sets in your code to store indexes into some other data structure. For example, given an NSArray object, you could use an index set to identify a subset of objects in that array.

NSIndexSet is a Foundation Framework collection class that is similar to NSRange, with the notable exception of being able to support non-contiguous series. An NSIndexSet can be created from a range using the indexSetWithIndexesInRange: class constructor:

NSIndexSet expresses a collection of unique whole numbers; its purpose is to express element numbers of an ordered collection, such as an NSArray. It is available in iOS 2.0 and later, available in OS X v10.3 and later . An NSIndexSet is immutable; its mutable subclass is NSMutableIndexSet. You can form a simple NSIndexSet consisting of just one contiguous range directly, by passing an NSRange to indexSetWithIndexesInRange: but to form a more complex index set you’ll need to use NSMutableIndexSet so that you can append additional ranges.

Example :

    NSRange range = NSMakeRange(0, 10);
    NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:range];

Related Source:

56 questions
0
votes
1 answer

How to get an int out of selectedRowIndexs in Swift?

I haven't worked in Xcode, Objective C or Cocoa before, and I decided to give Swift a try. The simple app I'm building (for Mac OS, not iOS) displays in a table view some data stored in an array. I'm trying to let the user delete a selected row, the…
Iacopo Boccalari
  • 1,115
  • 2
  • 11
  • 17
0
votes
3 answers

How can I select elements from an NSArray according to array of NSIndexPaths

Is there a fast way to get all elements at indexes from an array returned from a UITableView (NSArray of NSIndexPaths). For instance: [self.dataSourceArray selectItemsAt:[self.tableView indexPathsForSelectedItems]]
Avner Barr
  • 13,049
  • 14
  • 82
  • 152
0
votes
1 answer

NSMutableIndexSet addIndex: Method Throws Error

In trying to delete some objects from Core Data, I am running into some difficulty using the NSMutableIndexSet class and it's method 'addIndex:'. In core data I have folder objects, which contain a set of thread objects. Each thread has a threadId…
jac300
  • 4,832
  • 12
  • 49
  • 87
0
votes
1 answer

Finding the nth entry in an nsindexset

Say i have an NSIndexSet called aSet with numbers ranging from 26-89. [aSet firstIndex] gives me 26 [aSet lastIndex] gives me 89 What method would give the 3rd index (29)?
MoKaM
  • 383
  • 1
  • 3
  • 7
0
votes
2 answers

Index of highest index in NSMutableIndexSet

How can I get the index of the highest (numerical) index contained in an NSMutableIndexSet? I.e the position in which the highest NSUInteger (index) is in the NSMutableIndexSet? NSArray *results = [subCategory…
max_
  • 22,619
  • 38
  • 116
  • 207
0
votes
2 answers

How to remove duplicates from NSIndexSet?

What's the best way to remove duplicate indices from an NSIndexSet? For example, say my NSIndexSet looks like this: [ 1, 3, 3, 6, 7, 12, 12, 12 ] I want it to look like: [ 1, 3, 6, 7, 12 ] What's the most efficient way to accomplish this?
zakdances
  • 16,715
  • 30
  • 94
  • 155
0
votes
1 answer

Is there some way to store indexes of objects passing a test other than NSIndexSet?

I have a table and search bar. The table is generated from a SQLite DB and the search bar searches those objects. The problem I had was when I wanted to know what was the index of the search result, if I just looked at the array of search results…
lemontwist
  • 301
  • 9
  • 24
0
votes
1 answer

Create NSIndexSet from indexPathsForSelectedRows

I've got a nav controller that moves between two tableviews. The first table view has a right detail text label, like the settings app, that I'd like to display the selected options (allows multiple selections). Unfortunately, im having trouble…
Sean Danzeiser
  • 8,731
  • 12
  • 49
  • 84
-1
votes
1 answer

UITableView commitEditingStyle: used with expanding and collapsing sections

I have a UITableView with expanding and collapsing sections. Each section header is actually the row at index 0 for each section. Let's say that section contains six items, tapping on the header row (index 0) causes and additional six rows to be…
beev
  • 1,127
  • 2
  • 15
  • 33
-1
votes
1 answer

When is the index count of keys in NSDictionary greater than 1?

// 1 - Find the matching item index NSIndexSet* indexes = [[self.orderItems allKeys] indexesOfObjectsPassingTest:^BOOL(id obj, NSUInteger idx, BOOL *stop) { IODItem* key = obj; return [searchItem.name isEqualToString:key.name] && …
-2
votes
1 answer

UITableView reload sections crashes

I'm using [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:k] withRowAnimation:UITableViewRowAnimationNone];, I examined I'm getting a valid value for k but still I'm getting -[NSIndexSet initWithIndexesInRange:]: Range…
Nagesh
  • 157
  • 1
  • 2
  • 11
1 2 3
4