I'm building a rather long form with QuickDialog and Reactive Cocoa and I would love to be able to write a factory method to setup my QElements from the same form.
Here's my example of how I'm doing it now.
self.root = [[QRootElement alloc] init];
self.root.title = self.title;
self.root.grouped = YES;
self.basic = [[QSection alloc] init];
self.basic.title = @"Basic Information";
[self.root addSection:self.basic];
QEntryElement *address = [[QEntryElement alloc] init];
address.title = @"Address";
RAC(address, textValue) = [RACObserve(self, viewModel.address) distinctUntilChanged];
RAC(self, viewModel.address) = [RACObserve(address, textValue) distinctUntilChanged];
[self.basic addElement:address];
QEntryElement *city = [[QEntryElement alloc] init];
city.title = @"City";
RAC(city, textValue) = [RACObserve(self, viewModel.city) distinctUntilChanged];
RAC(self, viewModel.city) = [RACObserve(city, textValue) distinctUntilChanged];
[self.basic addElement:city];
QEntryElement *state = [[QEntryElement alloc] init];
state.title = @"State";
RAC(state, textValue) = [RACObserve(self, viewModel.state) distinctUntilChanged];
RAC(self, viewModel.state) = [RACObserve(state, textValue) distinctUntilChanged];
[self.basic addElement:state];
QEntryElement *postal = [[QEntryElement alloc] init];
postal.title = @"Zip";
RAC(postal, textValue) = [RACObserve(self, viewModel.postalCode) distinctUntilChanged];
RAC(self, viewModel.postalCode) = [RACObserve(postal, textValue) distinctUntilChanged];
[self.basic addElement:postal];
QEntryElement *phone = [[QEntryElement alloc] init];
phone.title = @"Phone";
RAC(phone, textValue) = [RACObserve(self, viewModel.phoneNumber) distinctUntilChanged];
RAC(self, viewModel.phoneNumber) = [RACObserve(phone, textValue) distinctUntilChanged];
[self.basic addElement:phone];
I would like to be able to call a method like:
-(QEntryElement *)racEntryElementWithTitle:(NSString *)title andModel(ViewModel *)model andProperty:(NSString*)property;
Is there some way to do this?