set business object after viewDidLoad

2 posts, 1 answers
  1. Mathieu
    Mathieu avatar
    11 posts
    Member since:
    Nov 2014

    Posted 10 Sep 2015 Link to this post


    I'm fetching business data from a server asynchronously ans thus I don't yet have access to the instance of a business object in viewDidLoad. So my setup code looks roughly like the following:

    TKDataForm *dataForm = [[TKDataForm alloc] initWithFrame:self.view.bounds];
    dataForm.delegate = self;
    [self.view addSubview:dataForm];
    self.dataSource = (TKDataFormEntityDataSource *)dataForm.dataSource;
    [myDataSource executeQueryOnCompletion:^(id value) {
        self.dataSource.selectedObject = value;

    However, the problem is that no form will displayed whatsoever. The screen just stays empty. This if even reproducible by changing the example from the documentation such that the business object is set in viewDidAppear: instead of viewDidLoad:


    - (void)viewDidAppear:(BOOL)animated {
        [super viewDidAppear:animated];
        self.dataSource.selectedObject = [PersonalInfo new];

    So it looks like the business object has to be set in viewDidLoad by all means. This isn't very flexible, are there any ways around this limitation?

  2. Answer
    Adrian avatar
    159 posts

    Posted 10 Sep 2015 Link to this post

    Hi Mathieu,

    Thank you for contacting us.

    I was able to reproduce the described issue. To workaround it you should invoke the reset method that is not visible in the public header of TKDataFormEntityDataSource using a selector after you set the selectedObject. Then you should call reloadData method of the data form. Please consider the code snippet below:
    - (void)viewDidAppear:(BOOL)animated
        [super viewDidAppear:animated];
        _dataSource.selectedObject = [PersonalInfo new];
        [_dataSource performSelector:@selector(reset)];
        [self.dataForm reloadData];

    Please keep in mind that currently TKDataForm is beta and I can't guarantee that this will work after our next release. The described issue will be addressed in the next version of TelerikUI for iOS. Our next release is scheduled for the end of this month.

    I hope this helps. If you need further assistance, do not hesitate to contact us.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft banner
Back to Top