Quicksort for Objective-C
- (NSMutableArray *) quickSort: (NSMutableArray *)toSort{
    for(NSNumber *arrayMember in toSort){
        if(![arrayMember respondsToSelector:@selector(doubleValue)]){
                NSLog(@"incorrect types in input array, returning nil");
                return nil;
            }
    }

    /* stuff */
}



There is a lot to comment on in just this part of your code, so that's where my focus will lie.



First of all, given that we're working with a mutable array, we should simply sort it in place--and we should make the method a category of NSMutableArray itself.

@interface NSMutableArray(QuickSort)

- (void)quickSort;

@end


So it can be used as such:

NSMutableArray *myArray = /* array instantiation */

[myArray quickSort];


I'd make a similar category for the immutable NSArray class which returns the sorted array:

@interface NSArray(QuickSort)

- (NSArray *)quickSortedArray;

@end


And that'd be used as such:

NSArray *unsorted = /* array instantiation */

NSArray *sorted = [unsorted quickSortedArray];


This makes our method signature make more sense.  Of course, NSMutableArray is a subclass of NSArray, so we can always apply the quickSortedArray method to an NSMutableArray as well, while the first recommendation (the simple quickSort method) simply sorts it in place and returns nothing.



So, that cleans up our method signature.  It makes it nice, and closer to what we'd expect to see with normal Objective-C methods.

But we've got a bigger problem.

Without documenting it, your method only works for objects which responds to the doubleValue selector, and inexplicably returns nil if anything else exists in the method.

Moreover, it can only sort the array in a single direction: ascending.

Rather than the zero argument quickSort or quickSortedArray methods I recommended, what we actually need is to accept some argument that tells us by what logic to sort the array.

We need a NSComparator argument.  This is what NSComparator is:

typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);


In plain English, NSComparator is a block which takes two arguments (of any object type) and returns an NSComparisonResult (which describes how these two objects should be sorted).

So we want our quickSort method to take one of these and use this for the logic to sort the array.  Let the caller specify how they should be sorted.

So, if as a caller of the quickSort method, I know my array contains only NSNumber objects, I can pass a comparator that treats the two inputs as strictly NSNumber, and it doesn't impact your implementation of the sorting logic.