Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // SecondViewController.m
- // BabyNamesGeneratorPro
- //
- #import "SecondViewController.h"
- @interface SecondViewController ()
- @end
- @implementation SecondViewController
- @synthesize saveName;
- @synthesize babyname;
- @synthesize generateGName;
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
- }
- - (void)viewDidUnload
- {
- [self setSaveName:nil];
- [self setBabyname:nil];
- [self setGenerateGName:nil];
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- }
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- {
- return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
- }
- - (IBAction)generateGName:(id)sender {
- int a = arc4random() % 49;
- int b = arc4random() % 49;
- // populate the array for the names
- NSArray *firstNameArray = [NSArray arrayWithObjects: @"Isabella",
- @"Sophia",
- @"Emma",
- @"Olivia",
- @"Ava",
- @"Emily",
- @"Abigail",
- @"Madison",
- @"Chloe",
- @"Mia",
- @"Addison",
- @"Elizabeth",
- @"Ella",
- @"Natalie",
- @"Samantha",
- @"Alexis",
- @"Lily",
- @"Grace",
- @"Hailey",
- @"Alyssa",
- @"Lillian",
- @"Hannah",
- @"Avery",
- @"Leah",
- @"Nevaeh",
- @"Sofia",
- @"Ashley",
- @"Anna",
- @"Brianna",
- @"Sarah",
- @"Zoe",
- @"Victoria",
- @"Gabriella",
- @"Brooklyn",
- @"Kaylee",
- @"Taylor",
- @"Layla",
- @"Allison",
- @"Evelyn",
- @"Riley",
- @"Amelia",
- @"Khloe",
- @"Makayla",
- @"Aubrey",
- @"Charlotte",
- @"Savannah",
- @"Zoey",
- @"Bella",
- @"Kayla", nil];
- NSArray *middleNameArray = [NSArray arrayWithObjects: @"Alexa",
- @"Peyton",
- @"Audrey",
- @"Claire",
- @"Arianna",
- @"Julia",
- @"Aaliyah",
- @"Kylie",
- @"Lauren",
- @"Sophie",
- @"Sydney",
- @"Camila",
- @"Jasmine",
- @"Morgan",
- @"Alexandra",
- @"Jocelyn",
- @"Gianna",
- @"Maya",
- @"Kimberly",
- @"Mackenzie",
- @"Katherine",
- @"Destiny",
- @"Brooke",
- @"Trinity",
- @"Faith",
- @"Lucy",
- @"Madelyn",
- @"Madeline",
- @"Bailey",
- @"Payton",
- @"Andrea",
- @"Autumn",
- @"Melanie",
- @"Ariana",
- @"Serenity",
- @"Stella",
- @"Maria",
- @"Molly",
- @"Caroline",
- @"Genesis",
- @"Kaitlyn",
- @"Eva",
- @"Jessica",
- @"Angelina",
- @"Valeria",
- @"Gabrielle",
- @"Naomi",
- @"Mariah",
- @"Natalia",
- @"Paige",
- @"Rachel", nil];
- // concatenate strings at index of array
- NSString *fullName = [NSString stringWithFormat:@"%@ %@", [firstNameArray objectAtIndex:a], [middleNameArray objectAtIndex:b]];
- // display the newly created first & middle names
- babyname.text = fullName;
- }
- - (IBAction)saveName:(id)sender {
- // save current baby name to array
- NSMutableArray *babyNameArray = [[NSMutableArray alloc] init];
- [babyNameArray addObject:babyname.text];
- // save list of babynames to nsuserdefaults
- [[NSUserDefaults standardUserDefaults] setObject:babyNameArray forKey:@"My Key"];
- // for testing log names listed in nsuserdefaults
- NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement