Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

timbojill

macrumors member
Original poster
May 21, 2011
31
0
Whenever the user clicks begin knuckle gets call no matter which row is highlighted. Can someone help me out.

Code:
#import "Push-Up of the Day.h"
#import "RegularPushup.h"
#import "inclinePushupHandsElevated.h"
#import "PushupfromKnee.h"
#import "KnucklesPushUp.h"

@implementation Push_Up_of_the_Day

@synthesize picker;
@synthesize mlabel;
@synthesize rlabel;
@synthesize slabel;

-(IBAction)Begin:(id) sender
{
	
	if (mlabel.text = @"Knuckles Pushup") 
	{
		KnucklesPushUp *view=[[KnucklesPushUp alloc] initWithNibName:nil bundle:nil];
		view.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
		[self presentModalViewController:view animated:YES];
		[view release];
	}
	
	else if (mlabel.text = @"Incline Pushup (Hands Elevated)")   
	{
		inclinePushupHandsElevated *view=[[inclinePushupHandsElevated alloc] initWithNibName:nil bundle:nil];
		view.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
		[self presentModalViewController:view animated:YES];
		[view release];
	}
	
	else if (mlabel.text = @"Pushup from Knee")   
	{
		PushupfromKnee *view=[[PushupfromKnee alloc] initWithNibName:nil bundle:nil];
		view.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
		[self presentModalViewController:view animated:YES];
		[view release];
	}
	
	/*
	else if (mlabel.text = @"Regular Pushup") 
	{
		RegularPushup *view=[[RegularPushup alloc] initWithNibName:nil bundle:nil];
		view.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
		[self presentModalViewController:view animated:YES];
		[view release];
	}
	*/
}

//---------------------------------------------------------------------------------
// Code for UIPICKER. Component 0 is Column 1, Component 

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;
{
	return 3;
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
	if(component == 0)
		
	{
		mlabel.text= [arrayNo objectAtIndex:row];
		
	}
	
	else if(component == 1)
		
	{
		
	rlabel.text= [arrayRep objectAtIndex:row];
		
	}
	
	else if(component == 2)
	{
		
		slabel.text= [arraySet objectAtIndex:row];
		
	}
	
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;
{
	if(component == 0)
		
	{
		
		return [arrayNo count];
		
	}
	
	else if(component == 1)
		
	{
		
		return [arrayRep count];
		
	}
	
	else if(component == 2)
	{
		
	return [arraySet count];
		
	}
	
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;
{
	if(component == 0)
		
	{
		return [arrayNo objectAtIndex:row];		
	}
	
	else if(component == 1)
		
	{
		return [arrayRep objectAtIndex:row];
	}
	
	else if(component == 2)
	{		
		return [arraySet objectAtIndex:row];			
	}
	
}


-(IBAction)textFieldReturn:(id)sender
{
	[sender resignFirstResponder];
}

- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component {
    if (component == 0) {
        return 200;
    }
    else {
        return 44;
    } 
}

-(IBAction)RegularPushup:(id) sender
{
	RegularPushup *view=[[RegularPushup alloc] initWithNibName:nil bundle:nil];
	view.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
	[self presentModalViewController:view animated:YES];
	[view release];
}



-(IBAction)InclinePushupHandsElevated:(id) sender
{
	inclinePushupHandsElevated *view=[[inclinePushupHandsElevated alloc] initWithNibName:nil bundle:nil];
	view.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
	[self presentModalViewController:view animated:YES];
	[view release];
}
 

-(IBAction)PushupfromKnee:(id) sender
{
	PushupfromKnee *view=[[PushupfromKnee alloc] initWithNibName:nil bundle:nil];
	view.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
	[self presentModalViewController:view animated:YES];
	[view release];
}

-(IBAction)KnucklesPushUp:(id) sender
{
	KnucklesPushUp *view=[[KnucklesPushUp alloc] initWithNibName:nil bundle:nil];
	view.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
	[self presentModalViewController:view animated:YES];
	[view release];
}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
// [super viewDidLoad];

	[super viewDidLoad];
	arrayNo = [[NSMutableArray alloc] init];
	[arrayNo addObject:@""];
	[arrayNo addObject:@"Regular Pushup"];
	[arrayNo addObject:@"Incline Pushup (Hands Elevated)"];
	[arrayNo addObject:@"Pushup from Knee"];
	[arrayNo addObject:@"Knuckles PushUp"];
	[arrayNo addObject:@"One Leg Up Pushup"];
	[arrayNo addObject:@"Alt. Hands Pushup"];
	[arrayNo addObject:@"Regular Pushup w/ Wide Legs"];
	[arrayNo addObject:@"Wide Grip Pushup"];
	[arrayNo addObject:@"Triangle"];
	[arrayNo addObject:@"Half Triangle"];
	[arrayNo addObject:@"T Pushup"];
	[arrayNo addObject:@"L Pushup"];
	[arrayNo addObject:@"Knee Forward Pushup"];
	[arrayNo addObject:@"Elbow to Ground Pushup"];
	[arrayNo addObject:@"Hove Pushup"];
	[arrayNo addObject:@"Hands on Blocks"];
	[arrayNo addObject:@"Dumbell Pushup  "];
	[arrayNo addObject:@"Barbell Pushup  "];
	[arrayNo addObject:@"Medium (30)"];
	[arrayNo addObject:@"Spiderman"];
	[arrayNo addObject:@"Judo Pushup"];
	[arrayNo addObject:@"Reverse Judo Pushup"];
	[arrayNo addObject:@"Reverse Judo Pushup"];
	[arrayNo addObject:@"Pike Pushup"];
	[arrayNo addObject:@"Tricep Extension"];
	[arrayNo addObject:@"Alt. Hands One Leg Up"];
	[arrayNo addObject:@"Knee Side Up"];
	[arrayNo addObject:@"Knee Side Down"];
	[arrayNo addObject:@"Opposite Elbow"];
	[arrayNo addObject:@"Hands on Blocks/One Leg"];
	[arrayNo addObject:@"Dumbell Pushup/ One Leg"];
	[arrayNo addObject:@"Barbell Pushup/ One Leg"];
	[arrayNo addObject:@"Feet Elevated"];
	[arrayNo addObject:@"Med. Ball 2 Hands"];
	[arrayNo addObject:@"Double Med. Ball"];
	[arrayNo addObject:@"Double Med. Ball One Foot"];
	[arrayNo addObject:@"Med. Ball Alternating"];
	[arrayNo addObject:@"Swiss Ball Feet Elevated Pushup"];
	[arrayNo addObject:@"Suspended Pushup From Feet"];
	[arrayNo addObject:@"Hurdle Pushup"];
	[arrayNo addObject:@"Diamond Grip"];
	[arrayNo addObject:@"Hand over Hand"];
	[arrayNo addObject:@"Warrior Pushup"];
	[arrayNo addObject:@"Fingertip Pushup (5 Fingers)"];
	[arrayNo addObject:@"Plyo One Arm Forward"];
	[arrayNo addObject:@"Plyo One Arm Chest Touch"];
	[arrayNo addObject:@"Plyo One Arm Ear Touch"];
	[arrayNo addObject:@"Plyo Both Hands Off"];
	[arrayNo addObject:@"Plyo Clap Pushup"];
	[arrayNo addObject:@"Hard (34)"];
	[arrayNo addObject:@"Single Arm Pushup"];
	[arrayNo addObject:@"Feet Elevated Single Arm Pushup"];
	[arrayNo addObject:@"Single Arm /Leg Pushup"];
	[arrayNo addObject:@"One Arm Spider Man"];
	[arrayNo addObject:@"Fingertip Pushup (3 Index, middle, thumb)"];
	[arrayNo addObject:@"Corkscrew Pushup"];
	[arrayNo addObject:@"Oval Pushup"];
	[arrayNo addObject:@"Hip Twist Pushup"];
	[arrayNo addObject:@"Scorpion"];
	[arrayNo addObject:@"Foot Kick"];
	[arrayNo addObject:@"Leg Out to the Side"];
	[arrayNo addObject:@"Swiss Ball One Foot Elevated Pushup "];
	[arrayNo addObject:@"Swiss Ball Two Hands"];
	[arrayNo addObject:@"Feet Elevated Two Hands Swiss Ball"];
	[arrayNo addObject:@"Double Swiss Ball"];
	[arrayNo addObject:@"Pike Pushup Swiss Ball"];
	[arrayNo addObject:@"Chain Pushup"];
	[arrayNo addObject:@"Band Pushup"];
	[arrayNo addObject:@"Bosu Pushup"];
	[arrayNo addObject:@"Football Pushup"];
	[arrayNo addObject:@"Dumbell Pushup to Row"];
	[arrayNo addObject:@"Suspended Pushup from Hands"];
	[arrayNo addObject:@"Plyo Chest Touch Pushup"];
	[arrayNo addObject:@"Plyo Alternating Hand Switches Pushup"];
	[arrayNo addObject:@"Plyo Ear Touch"];
	[arrayNo addObject:@"Plyo Both Arms Up"];
	[arrayNo addObject:@"Plyo Hip Slap"];
	[arrayNo addObject:@"Plyo Hands/Feet Up"];
	[arrayNo addObject:@"Plyo Alt. Hip and Hand Up Slap"];
	[arrayNo addObject:@"Plyo Wide to Clost Grip Pushup"];
	[arrayNo addObject:@"Plyo Box Pushups"];
	[arrayNo addObject:@"Partner on your back With Hands"];
	[arrayNo addObject:@"Wall Pushup"];
	[arrayNo addObject:@"Handstand Pushup"];
	[arrayNo addObject:@"Inchworm Pushups"];
	[arrayNo addObject:@"Alligator Pushups"];
	[arrayNo addObject:@"Tiger Pushups"];
	[arrayNo addObject:@"Spider Sidewalk and Pushup"];
	
	
	[pickerView selectRow:1 inComponent:0 animated:NO];
    mlabel.text= [arrayNo objectAtIndex:[pickerView selectedRowInComponent:0]];	
	
	arrayRep = [[NSMutableArray alloc] init];
	[arrayRep addObject:@"01"];
	[arrayRep addObject:@"02"];
	[arrayRep addObject:@"03"];
	[arrayRep addObject:@"04"];
	[arrayRep addObject:@"05"];
	[arrayRep addObject:@"06"];
	[arrayRep addObject:@"07"];
	[arrayRep addObject:@"08"];
	[arrayRep addObject:@"09"];
	[arrayRep addObject:@"10"];
	[pickerView selectRow:1 inComponent:0 animated:NO];
    rlabel.text= [arrayNo objectAtIndex:[pickerView selectedRowInComponent:0]];	
	
	arraySet = [[NSMutableArray alloc] init];
	[arraySet addObject:@"01"];
	[arraySet addObject:@"02"];
	[arraySet addObject:@"03"];
	[arraySet addObject:@"04"];
	[arraySet addObject:@"05"];
	[arraySet addObject:@"05"];
	[arraySet addObject:@"06"];
	[arraySet addObject:@"07"];
	[arraySet addObject:@"08"];
	[arraySet addObject:@"09"];
	[arraySet addObject:@"10"];
	
	[pickerView selectRow:1 inComponent:0 animated:NO];
    slabel.text= [arrayNo objectAtIndex:[pickerView selectedRowInComponent:0]];	

}
 

admanimal

macrumors 68040
Apr 22, 2005
3,531
2
<KABOOM!>

Sorry, that was just the sound of my programmer head exploding when I saw "Push-Up of the Day.h".

But anyway, that isn't the problem. Never compare strings with == (actually, you are using =, which is even less correct). What you should be doing is this:

if ([mlabel.text isEqualToString:mad:"Knuckles Pushup"])...

It's not necessarily the only problem, but it's the first that I noticed.
 
Last edited:

timbojill

macrumors member
Original poster
May 21, 2011
31
0
Thank you very much. Modding the if statment like you said really worked. Now I have another problem. This App is a Tab View App. I want to add a back button to every page that the begin button switches too. Problem is when I put a back button to Regular Pushup it just shows a white screen. I guess this is becuase Push-up of the day is in a tab view. How do i GO ABOUT FIXING IT.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.