views:

49

answers:

2

hi, i want simply to show a double value on a uialert view it is possible?

A: 

How are you showing the UIAlertView now? Something like the following should work:

double myDouble = 12.6;
NSString *alertString = [NSString stringWithFormat:@"%g", myDouble];
UIAlertView *myAlert = [[UIAlertView alloc] initWithTitle:alertString
                                                  message:nil
                                                 delegate:nil
                                        cancelButtonTitle:nil
                                        otherButtonTitles:nil];
[myAlert show];
Carl Norum
+2  A: 

Put the value into a formatted NSString and send that to the alertView:

NSString *messageString = [NSString stringWithFormat:"@number = %.2f", 42.0];


UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Title text" message:messageString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
davbryn