Created
November 24, 2011 00:44
-
-
Save Hunter-Dolan/1390366 to your computer and use it in GitHub Desktop.
random.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <stdlib.h> | |
+ (NSNumber *)randomFourDigitNumber | |
{ | |
int randomNumber = rand()%9999 + 1000; | |
NSArray *badNumbers = [NSArray arrayWithObjects:@"69",@"666",@"0",@"11",@"22",@"33",@"44",@"55",@"66",@"77",@"88",@"99", nil]; | |
for (NSString *badNumber in badNumbers) { | |
if ([[NSString stringWithFormat:@"%i",randomNumber] rangeOfString:badNumber].location != NSNotFound) { | |
randomNumber = [[self randomFourDigitNumber] intValue]; | |
} | |
} | |
return [NSNumber numberWithInt:randomNumber]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment