I've initialized a QLabelElement, and then later want to update its value. However explicitly setting the .value property on the instance of QLabelElement doesn't update its value. Here is a snippet of what I'm trying to do. The onSelected delegate is executed when the sayHello button is pressed, but the label element isn't updated:
@implementation MyController { QLabelElement *_theLabel; } - (id)init { self = [super init]; QRootElement *root = [[QRootElement alloc] init]; QSection *section = [[QSection alloc] init]; _theLabel = [[QLabelElement alloc] initWithTitle:@"The Label" Value:@""]; QSection *sectionButton = [[QSection alloc] init]; QButtonElement *sayHello = [[QButtonElement alloc] initWithTitle:@"Say Hello"]; [sections and controls added to root, etc] sayHello.onSelected = ^{ _theLabel.value = @"Hello has been said"; //<-- this isn't working }; //setting _theLabel.value = @"Hello has been said" here works, but not in the delegate self.root = root; return self; }
You need to reload the cell for that element after it's loaded. Also, be careful with retain loops, use weak variables:
__weak QLabelElement *weakLabel = _theLabel;
sayHello.onSelected = ^{
weakLabel.value = @"Hello has been said"; //<-- this isn't working
[self.quickDialogTableView reloadCellForElements:weakLabel, nil];
};
There's a branch of QD that resolves this automatically, but it's definitely not ready for consumption.