Skip to content

initWithCoder support #32

@wefish

Description

@wefish

I'm using segues on my project. Navigation is performed using code like

[self performSegueWithIdentifier:@"editData" sender:self];

And the data to be edited is asigned to destination view controller on the prepareForSeguemethod

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"editWorkerProfile"])
    {
        UINavigationController* navController = [segue destinationViewController];
        MyEditorViewController *editorController = (MyEditorViewController *) [navController topViewController];
        editorController.data = dataToBeEdited;
    }
}

The destination ViewController is initialized using "initWithCoder" and form structure is created on the "viewDidLoad" (Because data property is assigned after initialization).

With te "1.0.0" version of XLForm I used a "trick" like this on destination ViewController:

- (id)initWithCoder:(NSCoder*)aDecoder
{
    if(self = [super initWithCoder:aDecoder])
    {
        XLFormDescriptor * form  = [XLFormDescriptor formDescriptorWithTitle:@"work profile"];
        return [super initWithForm:form]; // Second init... it works with XLFrom 1.0.0!!!
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Form content is built after initialization
    [self buildForm: self.form withData: self.data]; 
}

With the actual git XLForm version this code is not working anymore: form appears empty...

¿What's the correct way to use XLForm with storyboard & segues?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions