Friday, 15 March 2013

xcode4.2 - Performing mathematical operations in Xcode using Text Fields? -



xcode4.2 - Performing mathematical operations in Xcode using Text Fields? -

i want utilize values entered in text fields users in 2 columns , perform necessary operations generate desired output , display result alert message in xcode? there way can perform calculations using text fields ?

got ans:

-(ibaction)buttonpressed1:(id)sender { // may need check if string info valid number int result = [number1.text intvalue] + [number2.text intvalue]; sumanswer.text = [nsstring stringwithformat:@"%d", result]; }

this above code correct. show result in 3rd textbox. if want show result in uialertview

try uialertview

uialertview *alert = [[uialertview alloc] initwithtitle:@"result !!" message:[nsstring stringwithformat:@"%d", result]; delegate:self cancelbuttontitle:@"ok" otherbuttontitles:nil]; // optional - add together more buttons: [alert addbuttonwithtitle:@"yes"]; [alert show];

and don't forget add together uialertviewdelegate in .h class

xcode4.2

No comments:

Post a Comment