Despite you’re casting NSMutableSet to NSArray, that simple casting won’t make NSSet class respond to NSArray‘s messages. You have to fill an actual NSArray with the elements of the NSSet like this:
NSArray *array = [theNsSet allObjects];