Random Name and Address Generator - Useful for Xcode Test Data

I wanted to have a way to generate random names, addresses, phone numbers, etc. I needed some xml data that I could read from a plist, to use with Xcode, so I wrote a generator.

I works very well for me, but I haven’t had anyone else look at it…

If you get a chance take a peek at :
http://www.journey-of-flight.com/bh_utility/random_names/random_name_generator.php

The generator is broken down into four parts :

Output Fields : select which fields you want for testing

Output Mode : {“MAIN”, “HTML”, “TEXT”, “XML”}

[ ] About - a little about the site and author (defaults to unchecked)
[x] Help - minor help, this generator is pretty simple to use.

[x] Header Row Uses : {$key, $value}
$key is in this format “home_phone”
$value is in this format “Home Phone”

[x] Pad SeqNo puts leading zeros :
two zeros if less than 1000 records
three zeros if more than 999 records

[x] Center Phone Numbers (alignment)
is used with the {“MAIN”} view, which is the HTML Table

( ) Delimiter : defaults to TAB for the HTML, and TEXT views, but can be changed

Range [10] : you can generate from 10 to 2000 records

Let me know :

( 1 ) if it's useful, and 
( 2 ) if you spot any problems I should fix

Best regards,

Bill Hernandez
Plano, Texas

Bill,

Thanks for creating this. I am finding it useful for experimenting with a database of sorts. My question is when you generate the XML version you offer up that the user can save it as an XML file or a PLIST, what are the advantages/differences in doing either. I would be using the file as a list for a mailing list.

Thanks,
Mark

I found a small glitch with the plist file, the first useful line that encompassed all the records ( …) was a dict and needed to be an ( … ), so that is fixed.

Here is how I am using the output from the generator.

Notice there is code for the header file (xxx.h), followed by the code for the class file (xxx.m)

The Application Document Window has a TableView with 11 columns, one corresponding to each defined kArrayKey_xxx

Here’s the code:

// ±--------±--------±--------±--------±--------±--------±--------±--------+
// BasicArrayAppDelegate.h
// BasicArray
//
// Created by Bill Hernandez on 2/6/10.
// Copyright 2010 journey-of-flight.com. All rights reserved.
// ±--------±--------±--------±--------±--------±--------±--------±--------+

#import <Cocoa/Cocoa.h>

@interface BasicArrayAppDelegate : NSObject {
NSWindow *window;

IBOutlet NSTableView*		tableView;

NSMutableArray*					peopleMutableArray;

}

@property (assign) IBOutlet NSWindow *window;

@end

// ±--------±--------±--------±--------±--------±--------±--------±--------+
// BasicArrayAppDelegate.m
// BasicArray
//
// Created by Bill Hernandez on 2/6/10.
// Copyright 2010 journey-of-flight.com. All rights reserved.
// ±--------±--------±--------±--------±--------±--------±--------±--------+

#import “BasicArrayAppDelegate.h”

// ±--------±--------±--------±--------±--------±--------±--------±--------+
// Keys for the entries in the data storage
// ±--------±--------±--------±--------±--------±--------±--------±--------+
#define kArrayKey_Seqno @“seqno” //NSString
#define kArrayKey_Fname @“fname” //NSString
#define kArrayKey_Middle @“middle” //NSString
#define kArrayKey_Lname @“lname” //NSString
#define kArrayKey_Street @“street” //NSString
#define kArrayKey_City @“city” //NSString
#define kArrayKey_St @“st” //NSString
#define kArrayKey_Zip @“zip” //NSString
#define kArrayKey_Home_Phone @“home_phone” //NSString
#define kArrayKey_Mobil_Phone @“mobil_phone” //NSString
#define kArrayKey_Work_Phone @“work_phone” //NSString
// ±--------±--------±--------±--------±--------±--------±--------±--------+
@implementation BasicArrayAppDelegate

@synthesize window;

// ±--------±--------±--------±--------±--------±--------±--------±--------+

  • (id) init {
    // Allocate some memory for the the data storage
    if(self = [super init])
    {
    peopleMutableArray = [NSMutableArray new];
    }
    return self;
    }
    // ±--------±--------±--------±--------±--------±--------±--------±--------+

  • (void) dealloc {
    // Release the memory allocated for the data storage
    [peopleMutableArray release];
    [super dealloc];
    }
    // ±--------±--------±--------±--------±--------±--------±--------±--------+

  • (void) awakeFromNib
    {
    // Don’t forget to add ‘people.plist’ to the Project, so it can be found in the mainBundle
    NSBundle *bundle = [NSBundle mainBundle];
    NSString *path = [bundle pathForResource: @“people” ofType: @“plist”]; // Read ‘people.plist’

    // The next code line will log the path that you can use to open the ‘people.plist’ via the Terminal
    NSLog(@“%@”, path);
    // From the Console copy the path, then open the Terminal and type :
    // $ open /whatever/path/you/copy/from/the/NSLog/Console/people.plist
    // This should have opened the plist, close it, and continue

    NSArray *arrayFromFile = [NSArray arrayWithContentsOfFile: path];

    // Add the objects to the data peopleMutableArray from the arrayFromFile containing ‘people.plist’
    if (arrayFromFile != nil)
    {
    [peopleMutableArray addObjects:(NSMutableArray *)arrayFromFile];
    }
    }
    // ±--------±--------±--------±--------±--------±--------±--------±--------+

  • (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application
    }
    // ±--------±--------±--------±--------±--------±--------±--------±--------+

  • (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication {
    return YES;
    }
    // ±--------±--------±--------±--------±--------±--------±--------±--------+
    @end