I’m trying to learn a little about Xcode, and I’m stuck on trying to get multiple values from a single input.
- (void)degreeConvert:(id)sender
{
double timelonn = [tempTextBox.text doubleValue];
double monedslonn = (timelonn * 162.5);
// double arslonn = (timelonn * 1950);
[tempTextBox resignFirstResponder];
NSString *convertResult = [[NSString alloc] initWithFormat: @"Månedslønn: %0.f", monedslonn];
// NSString *convertResult = [[NSString alloc] initWithFormat: @"Årslønn: %0.f", arslonn];
calcResult.text = convertResult;}
This takes my input ‘timelonn’ (hourly wage/income) and returns ‘monedslonn’ (monthly wage/income). The double-dashed comments is my rookie idea of how I could get it to display ‘arslonn’ (yearly wage/income) as well.
Am I far off here?
You’re not too far off. If you uncomment your first commented line, and then change your line where you set your convertResult, you can set the convertResult string to something with multiple lines, like so:
Note here that in the format string, “Månedslønn: %0.f\nÅrslønn: %0.f”, the \n stands for a newline.
Also note that you will have to edit your .nib and change a property of your UILabel. Click on the label and change the (I’m going off Xcode 4 here) Lines property to 2 (or however many lines you wanted). On Xcode 4 it should be the second from the top in the 4-th tab of the Utilities pane (Command-Option-4). While you’re at it, resize your UILabel so that it has enough space to hold your multiple lines 😉