Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homework Completed #27

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Added options data. segue still not working
cdolm92 committed Aug 15, 2015
commit 57abe7b635b018cd573d5d56bae6e303a71bad76
13 changes: 12 additions & 1 deletion OptionSelector/POTableViewController.h
Original file line number Diff line number Diff line change
@@ -8,6 +8,17 @@

#import <UIKit/UIKit.h>

@interface POTableViewController : UITableViewController
@interface POTableViewController : UITableViewController {
NSArray *donutsArray;
NSArray *cupcakesArray;
NSArray *jellybeansArray;
NSArray *macaroonsArray;

int pastryInt;

}

@property int pastryInt;


@end
102 changes: 45 additions & 57 deletions OptionSelector/POTableViewController.m
Original file line number Diff line number Diff line change
@@ -7,21 +7,32 @@
//

#import "POTableViewController.h"
#import "PastryCategories.h"




@interface POTableViewController ()

@end

@implementation POTableViewController

@synthesize pastryInt;

- (void)viewDidLoad {
[super viewDidLoad];

// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;

// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;

donutsArray =[[NSArray alloc]initWithObjects: @"Tres Leches Cake",@"Double Chocolate",@"Cream Brulee",@"Coconut Cream",@"Blueberry Cake",@"Strawberry Cake",@"Vanilla Bean",@"Rosemary Pineapple",@"Lavender Flowers",@"Coconut Lime", nil];

jellybeansArray = [[NSArray alloc]initWithObjects: @"Coconut",@"Bubble Gum",@"Root Beer",@"Mango",@"Tutti-Frutti",@"Cotton Candy",@"Vanilla Bean",@"Strawberry Short Cake",@"Lime",@"Lemon", nil];

cupcakesArray = [[NSArray alloc]initWithObjects: @"Boston Cream", @"Sugar Cookie", @"Tie Dye",@"Cookies & Cream",@"Cookie Dough", @"Red Velvet", @"Ice Cream Sundae", @"Root Beer", @"Chocolate Chip Pancake", @"Triple Chocolate Fudge", nil];

macaroonsArray = [[NSArray alloc]initWithObjects: @"Vanilla",@"Cherry", @"Peach", @"Rasberry", @"Rose", @"Banana", @"Kiwi", @"Strawberry", @"Green Tea",@"Caramel", nil];

}

- (void)didReceiveMemoryWarning {
@@ -32,71 +43,48 @@ - (void)didReceiveMemoryWarning {
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 0;

return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
// Return the number of rows in the section.

if (pastryInt == 0)
return [donutsArray count];
if (pastryInt == 1)
return [jellybeansArray count];
if (pastryInt == 2)
return [cupcakesArray count];
if (pastryInt == 3)
return [macaroonsArray count];

[self.tableView reloadData];
return 0;
}

/*

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];


UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PastryListIdentifier" forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"PastryListIdentifier"];

//configure cell
if (pastryInt == 0)
cell.textLabel.text = [donutsArray objectAtIndex:indexPath.row];
if (pastryInt == 1)
cell.textLabel.text = [jellybeansArray objectAtIndex:indexPath.row];
if (pastryInt == 2)
cell.textLabel.text = [cupcakesArray objectAtIndex:indexPath.row];
if (pastryInt == 3)
cell.textLabel.text = [macaroonsArray objectAtIndex:indexPath.row];

}


return cell;
}

*/


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
} else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/

@end
76 changes: 41 additions & 35 deletions OptionSelector/PastriesTableViewController.m
Original file line number Diff line number Diff line change
@@ -7,12 +7,14 @@
//

#import "PastriesTableViewController.h"
#import "POTableViewController.h"
#import "PastryCategories.h"

@interface PastriesTableViewController ()

@property NSArray *storePastryCategories;


-(void) setupPastryData;


@@ -21,93 +23,97 @@ -(void) setupPastryData;
@implementation PastriesTableViewController

- (void)viewDidLoad {

[super viewDidLoad];


[self setupPastryData];











self.navigationItem.title = @"Pastries";
self.navigationItem.title = @"Pastries";
}

#pragma mark - The Data


-(void) setupPastryData {

PastryCategories *donuts = [[PastryCategories alloc]init];
[donuts setPastryName: @"Doughnut"];
[donuts setPastryOptions:@[@"Tres Leches Cake",@"Double Chocolate",@"Cream Brulee",@"Coconut Cream",@"Blueberry Cake",@"Strawberry Cake",@"Vanilla Bean",@"Rosemary Pineapple",@"Lavender Flowers",@"Coconut Lime",]];


PastryCategories *jellybeans = [[PastryCategories alloc]init];
[jellybeans setPastryName: @"JellyBeans"];
[jellybeans setPastryOptions:@[@"Tres Leches Cake",@"Double Chocolate",@"Cream Brulee",@"Coconut Cream",@"Blueberry Cake",@"Strawberry Cake",@"Vanilla Bean",@"Rosemary Pineapple",@"Lavender Flowers",@"Coconut Lime",]];


PastryCategories *cupcakes = [[PastryCategories alloc]init];
[cupcakes setPastryName: @"Cupcakes"];
[cupcakes setPastryOptions:@[@"Tie-Dye",@"Red",@"Cream Brulee",@"Coconut Cream",@"Blueberry Cake",@"Strawberry Cake",@"Vanilla Bean",@"Rosemary Pineapple",@"Lavender Flowers",@"Coconut Lime",]];


PastryCategories *macaroons = [[PastryCategories alloc]init];
[macaroons setPastryName: @"Macaroons"];
[macaroons setPastryOptions:@[@"Tres Leches Cake",@"Double Chocolate",@"Cream Brulee",@"Coconut Cream",@"Blueberry Cake",@"Strawberry Cake",@"Vanilla Bean",@"Rosemary Pineapple",@"Lavender Flowers",@"Coconut Lime",]];



self.storePastryCategories = [[NSArray alloc]initWithObjects: donuts.pastryName,jellybeans.pastryName, cupcakes.pastryName, macaroons.pastryName, nil];



}






#pragma mark - Table view data source


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

return self.storePastryCategories.count;



}






- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PastriesIdentifier" forIndexPath:indexPath];

cell.textLabel.text=[self.storePastryCategories objectAtIndex:indexPath.row];




return cell;
}



#pragma Navigation


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"yourSegue" sender:self];

POTableViewController *pastryList = [[POTableViewController alloc]initWithNibName:@"POTableViewController" bundle:nil];

if ([[self.storePastryCategories objectAtIndex:indexPath.row] isEqual: @"Doughnut"]) {
pastryList.pastryInt = 0;
[pastryList setTitle:[self.storePastryCategories objectAtIndex:indexPath.row]];
}
if ([[self.storePastryCategories objectAtIndex:indexPath.row] isEqual: @"JellyBeans"]) {
pastryList.pastryInt = 1;
[pastryList setTitle:[self.storePastryCategories objectAtIndex:indexPath.row]];
}

if ([[self.storePastryCategories objectAtIndex:indexPath.row] isEqual: @"Cupcakes"]) {
pastryList.pastryInt = 2;
[pastryList setTitle:[self.storePastryCategories objectAtIndex:indexPath.row]];
}

if ([[self.storePastryCategories objectAtIndex:indexPath.row] isEqual: @"Macaroons"]) {
pastryList.pastryInt = 3;
[pastryList setTitle:[self.storePastryCategories objectAtIndex:indexPath.row]];
}



NSLog(@"preparing");


}