When save NSDecimalNumber
in EditViewController
, in DisplayTableViewController
value appear NaN
Please need advice to solve this issue. Thanks
My code:
- (IBAction)saveChanges:(id)sender {
editGift.nameOfGift = nameTextField.text;
editGift.priceOfGift = [NSDecimalNumber decimalNumberWithString:priceTextField.text];
AppDelegate *myApp = (AppDelegate *) [[UIApplication sharedApplication]delegate];
[myApp saveContext];
[self.delegate editGiftViewControllerDidSave:self];
}
Please watch video explanation
Input value:
currencyFormatter = [[NSNumberFormatter alloc]init];
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
personGift.priceOfGift = [NSDecimalNumber decimalNumberWithString:priceTextField.text];
Your code is unclear about when it applies the currency formatting, but given your video it is very likely that the value of the text field is "$6,000". That is not a number (thus "NaN").