I’m really new to programming with objective c and so I hope that you can help me. I want to use 3 intValues from textfields to calculate. I have done it like this:
-(int)om{
NSNumber *Om1 = [NSNumber numberWithInt:[self.Textfield1.text intValue]];
return [Om1 intValue];}
-(int)on{
NSNumber *On1 = [NSNumber numberWithInt:[self.Textfield2.text intValue]];
return [On1 intValue];}
-(int)lv{
NSNumber *Lv1 = [NSNumber numberWithInt:[self.Textfield3.text intValue]];
return [Lv1 intValue];}
Now I want to use an if-statement to calculate the sum and run a message on the screen. I want calculate whether Om1 + On1 is less than Lv1+4. Is it a good idea to use the if-statement?
You don’t need to write simpler function. I.E.:
There is no point in creating a
NSNumberinstance just to return value.You can use an
ifstatement to do what you want: