Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

27 lines (21 sloc) 0.595 kB
//
// NSArray_SMF.m
// SMFramework
//
// Created by Thomas Cool on 12/27/10.
// Copyright 2010 tomcool.org. All rights reserved.
//
#import "NSArray_SMF.h"
@implementation NSArray (SMFramework)
- (NSArray *) SMFShuffled
{
// create temporary autoreleased mutable array
NSMutableArray *tmpArray = [NSMutableArray arrayWithCapacity:[self count]];
for (id anObject in self)
{
NSUInteger randomPos = arc4random()%([tmpArray count]+1);
[tmpArray insertObject:anObject atIndex:randomPos];
}
return [NSArray arrayWithArray:tmpArray]; // non-mutable autoreleased copy
}
@end
Jump to Line
Something went wrong with that request. Please try again.