// // NSMutableArray+Additions.m // popquizshow // // Created by Ronny Fenrich on 2012-11-14. // Copyright (c) 2012 Kyle Langille. All rights reserved. // #import "NSMutableArray+Additions.h" @implementation NSMutableArray (Shuffling) - (void)shuffle { NSUInteger count = [self count]; for (NSUInteger i = 0; i < count; ++i) { // Select a random element between i and end of array to swap with. NSInteger nElements = count - i; NSInteger n = (arc4random() % nElements) + i; [self exchangeObjectAtIndex:i withObjectAtIndex:n]; } } @end