need a fake social security number generator for a comedy app Im writing. A start button will startup the app showing a "scanning" process (totally fake) and one of the scanning attribs will be a series of displayed ssn's.
I need to have about 20-40 or so of these faux 123-45-6789 type numbers, displaying for about 1/2 sec each.
I would love to have hypens as well.
Later I will add in faux images to represent "fingerprints", "maps", "mug shots". All for fun, nothing real here, except my code.
Three buttons:
1. START
2. STOP
3. CANCEL - same as stop but makes a funny sound
herez my code - it doesnt build correctly...
int min = 101;
int max = 987;
int firstblock = (arc4random() % (max - min)) + min;
return [NSString stringWithFormat:@"%d", firstblock];
int min2 = 10;
int max2 = 98;
int secondblock = (arc4random() % (max2 - min2)) + min;
return [NSString stringWithFormat:@"%d", secondblock];
int min3 = 1005;
int max3 = 9986;
int thirdblock = (arc4random() % (max3 - min3)) + min;
return [NSString stringWithFormat:@"%d", thirdblock];
thanks for the tip. The build does now succeed but the end result still fails, ie, iPhone simulator 3.2 crashes. Its amazing how difficult it was just to get this much done, Ive spent many hours perusing Dev Documentation, internet postings, and random stabs in the dark. Even highliting terms such as "NSSTring" and using the "lookup in documentation" is overwhelming. Dev docs strike me as mostly confirmatory for people who already know what they are looking for but need "spelling help".
By contrast, learning any other "language" such as Russian, Italian, Hungarian, one can simply go to RosettaStone.com and get polished, presentable, understandable material in step by step format.
Too bad they dont offer "XCode" !
Here's my modified code including your tip:
#import "random08ViewController.h"
@implementation random08ViewController
- (IBAction)random08
{
int min = 101;
int max = 987;
int firstBlock = (arc4random() % (max - min)) + min;
int min2 = 10;
int max2 = 98;
int secondBlock = (arc4random() % (max2 - min2)) + min;
int min3 = 1005;
int max3 = 9986;
int thirdBlock = (arc4random() % (max3 - min3)) + min;
}
------------------------------------------------------------------------------
And the only other file in play is the viewcontroller.h file which has:
<b><u><a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html%23//apple_ref/doc/uid/TP40004265-SW1
">String Format Specifiers</a></u></b>
The "%@" format takes an object as a parameter, and NSLog calls that object's -description method. Usually you use "%@" to pass in other strings.
If you pass in a simple type like an int or a float for a "%@", you will crash.
Do a search on "String Format Specifiers" in XCode and bookmark it. You will find yourself referring to that page of the docs over and over and over.
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.