Alex Rivera | Logout

How to use NSIndexSet

Asked 2010-12-19T23:35:05.497
32

In Objective-C, my program opens a window and displays a table. I want to have a specified row of the table highlighted.

How do I do this?

I seem to need the code

[myTableView selectRowIndexes:(NSIndexSet *) byExtendingSelection:(BOOL)];

I looked at the developer documentation, and figured out that the BOOL should be NO.

By looking at the NSIndexSet docs, I can't figure out what the right syntax should be.

Edit
Report

1 Answer

0

I seem to need the code

[myTableView selectRowIndexes:(NSIndexSet *) byExtendingSelection:(BOOL)];

No; those are casts without anything to cast, which is invalid.

Remove the casts and put values there instead.

I looked at the developer documentation, and figured out that the BOOL should be NO.

Yes, because you don't want to extend the selection, you want to replace it.

By looking at the NSIndexSet docs, I can't figure out what the right syntax should be.

The same as for passing any other variable or message expression.

You need to create an index set and then either stash it in a variable and pass that or pass the result of the creation message directly.

answered 2010-12-20T01:05:34.873

Your Answer