I'm new to Objective C. I'm experiencing issues whilst creating a unit conversion app. Here is the offending code (P.S I'm aware that isn't the correct conversion):
The problem is that when I press the convert button, it returns with the initialisation value of 0. I then have to press the button again to get my calculated value. Thank you.
Of course I'm a hugeee noob, this is my first day :).
-(IBAction)convert:(id)sender{
int unitType;
double unitTemp1 = [_tempField.text doubleValue];
double unitTemp2 = 0;
switch(unitType)
{
case 1:
//Celcius to Farenheight
NSLog(@"Celcius to Farenheight Selected");
unitTemp2 = unitTemp1*9;
break;
}
if([_array objectAtIndex:1])
{
unitType = 1;
}
NSString* resultString = [[NSString alloc] initWithFormat:@"%f",unitTemp2];
_tempResult.text = resultString;
//initwithformat
}