Search code examples
iosquickdialog

how to get values from QuickDialog in iOs


I need some help in QuickDialog. I am using this tutorial QuickDialog but i cannot find what i would like to do in my QuickDialog.

First i have a controller A that will transfer to controller B using QuickDialog, values are in controller A. Now, my problem is how can i access the values when I'm already in controller B.

For example: i have declared QEntryElement *amountEntry = [[QEntryElement alloc] initWithTitle:@"Amount" Value:@""]; in controller A and passed this on controller B, how will i access amountEntry in controller B.

I hope i have explained it well. Please help on this.


Solution

  • You can access all values within the QRootElement. One way to do so is setting the key property of every QElement and afterwards fetch all key-value pairs into a NSMutableDicionary like so:

    NSMutableDictionary *results = [[NSMutableDictionary alloc] init];
    [fooRootElement fetchValueIntoObject:results];
    

    You can use the onSelected completion code to trigger such action with a QButtonElement

    QSection *confirmButtonSection = [[QSection alloc] init];
    QButtonElement *confirmButton = [[QButtonElement alloc] initWithTitle:@"Accept"];
    [fooRootElement addSection:confirmButtonSection];
    [confirmButtonSection addElement:confirmButton];
    [confirmButton setOnSelected:(^{[self fetchResultsAndCheckThemAndDismissControllerBMethod];})];
    

    the button will then call the method on controller A which will leave you with a filled dictionary full of sweet information.