Sharing array between viewcontroller and main testApp

Hi All

I’ve come up against a problem, I hope someone can help.
I have a number of viewControllers in an app that can communicate with the main testApp no problem at all.
However, I wish to pass the contents of an array (postedNotes) from my main testApp to an array in one of the viewControllers (allPostedNotes).
I can’t seem to do this. Both arrays are NSMutableArrays, and I want them to be in sync, so as one changes in my testApp, the other changes. How do I pass the contents of my array in testApp into the viewController?
Any use of syntax such as

  
  
[allPostedNotes addObject:[self postedNotes objectAtIndex:[postedNotes count]]];  
  

fails

Unless there was a way of having the viewController just share the postedNotes array values and not have to declare and setup a brand new array?
Any advice very welcome!

Sacculi

OK, please ignore this…I figured it out… :slight_smile:

Hi sevenspiral.

Feel free to point out how you resolved it too for other people who have the same problem and find their way here…

Thank you…

Yes :slight_smile: good point!!

taking the contents of an array back in my main testApp.mm and using them within the viewController.mm is possible through using syntax like:

  
  
[[cell textLabel] setText:[_app->postedNotes objectAtIndex:indexPath.row]];  
  

where postedNotes is a NSMutableArray delared, initialised and populated completely in testApp.mm

sevenspiral