Converting UITextField string to double
How to get UITextField number input and convert it to double so it can be saved in core data as declared property value double ,priceField is my UITextField ,earn is my table array and price is my core data attribute with double value. Here is my code from save function: -(void) saveData{
NSString *string1 = priceField.text;
NSInteger *myInteger=[string1 integerValue];
result = myInteger;
priceField.text=[NSString stringWithFormat:@"%d",myInteger];
// earn.price = priceField.text; <<<<--------- work with strings
earn.price = result;
NSError *error;
if (![managedObjectContext save:&error])
{
NSLog(@"Problem saving: %@", [error localizedDescription]);
}
}
I tried a lot of combination with float , int and double but always wrong.This work with string but i need to get the numbers and do some math .
Last edited by alextattoo; 11-25-2011 at 01:51 PM.
|