Question

I have created one custom ViewController named SetValueVC with UITextView in it. During creating new product in my app I display UITableViewController with cell that need to be specify. If user click on some cell I display my UIViewController as detailView to allow setting parent UITableViewCells detailLabel.text value. I know how to pass data from child view by using delegate but how it works when there is for example 10 rows? Should I create 10 delegates methods for every row or just create object of SetValueVC for every row in didselectForRow method and use just one delegate method ? Thanks in advance

Was it helpful?

Solution

That could be an answer : Work with a singleton and use your model in your ViewController and your UITableViewController

in the .h :

+(MyModel *)shared;

in the .m :

static MyModel *myModel;

@implementation MyModel

+(MyModel *) shared{
    if (nil != myModel) {
        return myModel;
    }

    static dispatch_once_t pred;
    dispatch_once(&pred, ^{
        myModel = [[MyModel alloc] init];
    });
    return myModel;
}

In this way, you can access to your model anywhere of your app.

Hope that will help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top