Monday, June 17, 2013

NSIndexSet isEqualToIndexSet example in Objective C (iOS).


NSIndexSet isEqualToIndexSet

Indicates whether the indexes in the receiving index set are the same indexes contained in another index set.

- (BOOL)isEqualToIndexSet:(NSIndexSet *)indexSet

Parameters
indexSet
Index set being inquired about.

Return Value of [NSIndexSet isEqualToIndexSet]
YES when the indexes in the receiving index set are the same indexes indexSet contains, NO otherwise.

NSIndexSet isEqualToIndexSet example.
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    if ([SODocument class] == context && [@"arrayController.selectionIndexes" isEqualToString: keyPath])
    {
        NSIndexSet* selectionIndexes = ((SOWindowController*)object).arrayController.selectionIndexes;
        for (SOWindowController* wc in self.windowControllers)
        {
            if (![selectionIndexes isEqualToIndexSet: wc.arrayController.selectionIndexes])
            {
                wc.arrayController.selectionIndexes = selectionIndexes;
            }
        }
    }
}

End of NSIndexSet isEqualToIndexSet example article.