1

I'm setting a handful of global parameters that I will eventually insert into my sqlite db. One of the text fields should only have decimals put into it but I am having an issue when trying to set the NSDecimal variable to the text fields value.

global_Raw_Value = self.Value.text;//self.Valueis the text field

totally new to iOS dev so any help converting the text fields value(self.Value) into an NSDecimal so I can insert the values into a sqlite table would be much appreciated. Thanks

BamBamBeano
  • 464
  • 4
  • 13
  • 24

1 Answers1

2

Apple is not providing an easy way putting values into an NSDecimal, so you have to do this yourself. This thread will help you: Is there a way to create an NSDecimal without using NSNumber and creating autoreleased objects?

On the other hand you can just use a NSNumber or a regular float:

NSString *inputString = self.Value.text;
float inputFloat = [inputString floatValue];
NSNumber *mynumber = [NSNumber numberWithFloat:inputFloat] 
Community
  • 1
  • 1
dom
  • 11,894
  • 10
  • 51
  • 74