Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XLFormRowDescriptorTypeDecimal is not casting properly from NSString to double in the cell #514

Closed
eliang opened this issue Aug 20, 2015 · 0 comments

Comments

@eliang
Copy link

eliang commented Aug 20, 2015

I need some guidance on how to address this issue. If you have a XLFormRowDescriptorTypeDecimal row and you enter 0.94, it will display the value as 0.939999999999 due to the cast from NSString to double. I have traced this issue to

(void)textFieldDidChange:(UITextField *)textField {
  if([self.textField.text length] > 0) {
    if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeNumber] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeDecimal]){
      self.rowDescriptor.value =  @([self.textField.text doubleValue]);
    }
    ....
  }
}

Should it be instead, [NSDecimalNumber decimalNumberWithString: self.textField.text]?

Is this an issue that needs to be fixed in the branch, or is this best addressed by creating a custom row?

Thanks,
Edwin

@eliang eliang changed the title XLFormRowDescriptorTypeDecimal is not casting properly XLFormRowDescriptorTypeDecimal is not casting properly from NSString to double Aug 20, 2015
@eliang eliang changed the title XLFormRowDescriptorTypeDecimal is not casting properly from NSString to double XLFormRowDescriptorTypeDecimal is not casting properly from NSString to double in the cell Aug 20, 2015
mats-claassen added a commit that referenced this issue Jun 2, 2016
Fix decimal number formatting. closes #514
markrickert added a commit to markrickert/XLForm that referenced this issue Sep 29, 2016
* master: (27 commits)
  Add property in XLFormTextViewCell to limit number of characters
  Add property in XLFormTextFieldCell to limit number of characters
  change XLFormUnspecifiedHeight constant to not collide with Automatic dimension
  datePicker.locale property public to developer,for example, _birthdayRow = [XLFormRowDescriptor formRowDescriptorWithTag:kBirthdayTag rowType:XLFormRowDescriptorTypeDateInline title:@"Birthday"]; [_birthdayRow.cellConfig setObject:[[NSLocale alloc] initWithLocaleIdentifier:@"en"] forKey:@"locale"];
  Refactored '-(id)init' to '- (instancetype)init'
  Update 'initializeForm' example.
  Update pod badge
  [fixes xmartlabs#452] respect the currentLocale when parsing decimal values
  Remove the fix for suppressing "Empty snapshot" warnings when presenting action sheets
  Updated code to actually use the optionTitle variable
  Fixed selector action sheet to use the row's value transformer
  update pod version
  added count to empty check. Helpful to validate multiple selectors being empty
  Fix decimal number formatting. closes xmartlabs#514
  Added height property to XLFormRowDescriptor
  updated readme with some comments. Fixes xmartlabs#771, fixes xmartlabs#727, fixes xmartlabs#696
  Add support for NSFormatter
  Do validation can be nullable. fixes xmartlabs#705
  fix crash when using cell style Value2. closes xmartlabs#770
  Fix when the textFieldPercentage is applied. Closes xmartlabs#776
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant