nsrange

How do I store an NSRange in a NSMutableArray or other container?

Here's what I want to do: NSRange r = NSMakeRange(0,5); id a = [NSMutableArray a]; [a addObject: r]; // but NSRange is not a NSObject * With a boolean, I'd use code like this: [a addObject: [NSNumber numberWithBool: YES]]; or with an integer: [a addObject: [NSNumber numberWithInteger: 3]]; So what's the equivalent with a NSRange...

indexSetWithIndexesInRange is not doing what expected

I want to select some objects from an array. Therefore I'm using begin and end indexes of my selection. NSLog(@"start:%d\nend:%d", startIndex, endIndex); NSIndexSet *myIndexes = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(startIndex, endIndex)]; NSLog(@"%d", [myIndexes lastIndex]); The first NSLog gives me startIndex:49 ...

NSIntersectionRange with a 0 length argument

In Objective C, when using the function NSIntersectionRange with one of the arguments being zero length, does the result equal the other argument? Didn't see this when I searched so I wanted to clarify it for others. ...