You need to supply an object - any object specifying the value of the item being searched. As long as the comparator knows how to extract the value, the indexOfObject:inSortedRange:options:usingComparator:
would return a proper value.
You need to specify NSBinarySearchingInsertionIndex
option to make the search return the position of the first item that's greater than your target value by the smallest amount, i.e. the insertion index for your new value.
NSNumber *target = ... // Your target number
int index = [sortedArray indexOfObject:target
inSortedRange:NSMakeRange(0, sortedArray.count)
options:NSBinarySearchingInsertionIndex
usingComparator:^(id lhs, id rhs) {
return [lhs compare:rhs]
}];