How do I correctly convert a NSString to a double in xcode 3.2? This is my code(abbreviated), but when I run it, the message says (null). What am I doing wrong? Thanks so much!
@synthesize class1sem1;
-(IBAction)buttonPressed
{
NSString *myString = class1sem1.text;
double myDouble = [myString doubleValue];
NSString *message = [[NSString alloc] initWithFormat:
@"%@", myDouble];
UIAlertView *alert =[[UIAlertView alloc] initWithTitle:@"Result" message:message delegate:nil cancelButtonTitle:@"Great!" otherButtonTitles:nil];
[alert show];
[alert release];
[message release];
}
Use %g for your double .. not %@