Question

I have class A where array is:

@property(nonatomic, strong)NSMutableArray *tempClientNameArray;

I want to get the value of tempClientNameArray in class B. And, I'm doing like this:

- (void)viewDidLoad
{
    [super viewDidLoad];


    A *obj = [[A alloc]init];
    obj.view;
    clientlists =  obj.tempClientNameArray;
}

In this way I'm not getting value of tempClientNameArray.

Note: I need to assign tempClientNameArray to NSMutableArray clientlists

What I'm doing wrong? Please help.

No correct solution

OTHER TIPS

Do this to pass data from A to B..Put this code in A implementation file to switch A to B..

B *b = [[B alloc]init];
b.clientlists = tempClientNameArray;
[self.navigationController pushViewController:b animated:YES];

if you not use navigationController to switch do below code

B *b = [[B alloc]init];
b.clientlists = tempClientNameArray;
[self presentViewController:b animated:YES completion:nil];

I hope this will be helpful to you..

By doing this -

clientlists =  obj.tempClientNameArray;// wrong approach

You are storing address reference to an array.

This what you have to do.

NSMutableArray * clientlists =[NSMutableArray alloc]initWithArray:obj.tempClientNameArray];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top