Pooja
Pooja

Reputation: 2200

copy all values from 0ne array to another

identifierListController.nameArray = [[NSMutableArray alloc] initWithArray:nameArrayT copyItems:YES];

namearray is array of view controllers. I am reading values from webserver and putting into nameArrayT and then from nameArrayT to nameArray of the 2nd view which I select from the array.

I have tried:

  1. identifierListController.nameArray = [[NSMutableArray alloc]initWithArray:nameArrayT copyItems:YES];

  2. identifierListController.nameArray = [NSMutableArray arrayWithArray:nameArrayT];

  3. [identifierListController.nameArray addObject:soapResults1];

  4. [identifierListController.nameArray addObjectsFromArray:nameArrayT];

and all is not working for me, as when i am trying to display values of array by using NSLog() its shows null .

Do I have to create an NSString object and then copy that to the array? I hope some one knows how to do this.

Thanks :)

Upvotes: 1

Views: 2512

Answers (2)

Sabby
Sabby

Reputation: 2592

i hope you have made propery for name array and synthesized it as well,then you just need to do this.

@property(nonatomic,retain)NSMutableArray *nameArray;

and alloc this whether in LoadView,ViewDidLoad as you require.

[identifierListController.nameArray addObjectsFromArray:nameArrayT];

Or use this

NSMutableArray *nameArrayResult= [identifierListController.nameArray addObjectsFromArray:nameArrayT];

Now you can access array contents from nameArrayResult.

This will help you Good luck

Upvotes: 1

Misha
Misha

Reputation: 5380

Try first to allocate the array and then to copy objects:

identifierListController.nameArray = [NSMutableArray new];
[identifierListController.nameArray addObjectsFromArray:nameArrayT];

Upvotes: 4

Related Questions