Skip to content

Commit

Permalink
fix for crash xmartlabs#1044
Browse files Browse the repository at this point in the history
  • Loading branch information
liraz committed Feb 11, 2019
1 parent b65639b commit 2bff51d
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions XLForm/XL/Controllers/XLFormViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ -(instancetype)initWithCoder:(NSCoder *)aDecoder

- (void)dealloc
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc removeObserver:self name:UIContentSizeCategoryDidChangeNotification object:nil];
[nc removeObserver:self name:UIKeyboardWillShowNotification object:nil];
[nc removeObserver:self name:UIKeyboardWillHideNotification object:nil];

self.tableView.delegate = nil;
self.tableView.dataSource = nil;

Expand Down Expand Up @@ -575,18 +580,24 @@ -(void)reloadFormRow:(XLFormRowDescriptor *)formRow
-(XLFormBaseCell *)updateFormRow:(XLFormRowDescriptor *)formRow
{
XLFormBaseCell * cell = [formRow cellForFormController:self];
[self configureCell:cell];
[cell setNeedsUpdateConstraints];
[cell setNeedsLayout];
if (cell != nil) {
[self configureCell:cell];
[cell setNeedsUpdateConstraints];
[cell setNeedsLayout];
}
return cell;
}

-(void)configureCell:(XLFormBaseCell*) cell
{
[cell update];
[cell.rowDescriptor.cellConfig enumerateKeysAndObjectsUsingBlock:^(NSString *keyPath, id value, BOOL * __unused stop) {
[cell setValue:(value == [NSNull null]) ? nil : value forKeyPath:keyPath];
}];

if(cell.rowDescriptor != nil && cell.rowDescriptor.cellConfig != nil) {
[cell.rowDescriptor.cellConfig enumerateKeysAndObjectsUsingBlock:^(NSString *keyPath, id value, BOOL * __unused stop) {
[cell setValue:(value == [NSNull null]) ? nil : value forKeyPath:keyPath];
}];
}

if (cell.rowDescriptor.isDisabled){
[cell.rowDescriptor.cellConfigIfDisabled enumerateKeysAndObjectsUsingBlock:^(NSString *keyPath, id value, BOOL * __unused stop) {
[cell setValue:(value == [NSNull null]) ? nil : value forKeyPath:keyPath];
Expand Down

0 comments on commit 2bff51d

Please sign in to comment.