Hello to all. I am still very new at the iPhone programming so bear with me.
I am working on an app that uses the pickerView and am having some difficulties with it. I have the "wheels" populated and running correctly in the debugger. I can send the selected items to a string using NSLog, but what I want to do is, based on the users' selection in both components-do somehthing. Basically it is a measurement converter so in column 1 if teaspoon is selected and in column 2 tablespoon is selected, then convert the number of tsp to tbs(this number comes from a textbox that I do not have connected yet). Just trying to figure out how to get the selected index formatted correctly into an if statement. Then I will worry about the code for the conversion.
Here is my code for what is working and what I am trying to do with it. As stated above, I am able to get the selected items to show up in the NSLog, but to use the selected item in an if statement is my problem
Here is my code for what is working and what I am trying to do with it. As stated above, I am able to get the selected items to show up in the NSLog, but to use the selected item in an if statement is my problem
Code:
-(IBAction) calc:(id)sender
{
NSString* themessage = [NSString stringWithFormat:@"This %@ and this %@ are the measurements being converted.",
[from objectAtIndex:[calcPicker selectedRowInComponent:0]],
[to objectAtIndex:[calcPicker selectedRowInComponent:1]]];
//This is where I am trying to pull specific selections from the picker and then will do the conversions based on what is picked
if ([from objectAtIndex: [calcPicker selectedRowInComponent:0]] == 1) {
//do some coversion math here.....
}
NSLog(themessage);
}