0

So, I have a viewController, updatingIdentifiers, with a few textfields - all of which have a connected button, which puts the text from the textfield into a label (all in the same viewcontroller).

When you click to "Open this diary" and proceed to the next viewcontroller, you enter a UICollectionViewController, yourDiary. Each cell that the user creates in here, holds a couple of edible labels/textfield - but also holds a few labels, that should always have the text from the labels in the previous viewController, updatingIdentifiers.

So how do I set the labels in the UICollectionViewCells to have the data from the previous viewController's labels?

I tried storing the data from the labels in a seperate class, DiaryIdentifiers (NSObject), but I still couldn't find out how to access this data in the UICollectionViewController's code?

I'm pretty new in programming - and also don't if I should enter my code or a screenshots of my code here or if this will just be confusing?

Please let me know if pieces of the code will make it easier to help me! :)

Thanks a lot!

Anton

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
Anton Bjerg
  • 85
  • 2
  • 9
  • 2
    You definitely should include your code in your question in the form of a [mcve]. In most cases, _not including code_ is what makes a question confusing, especially if the question is about a specific problem about a specific piece of code. You should also have a look at the [ask] help page. – Dávid Pásztor Oct 03 '18 at 09:12
  • Possible duplicate of [iOS Swift: Pass data from ViewController to UITableViewCell](https://stackoverflow.com/questions/28922698/ios-swift-pass-data-from-viewcontroller-to-uitableviewcell) – Dris Oct 03 '18 at 09:12
  • 2
    Check this : https://stackoverflow.com/questions/5210535/passing-data-between-view-controllers – Amit Oct 03 '18 at 09:13
  • You should create a custom collectionViewCell, and with segue, you can pass data into the cell – Dris Oct 03 '18 at 09:14
  • Thanks for the different references - they are more about tableViews though and I find that the concepts are slightly different when working with CollectionViews, am I wrong? @Dris - should I use the prepareForSegue-code then? When passing data through the segue? Or how is this done? And will the data stay there, when I leave the viewcontroller later on, if I use this method? That is quite important, you see! :) – Anton Bjerg Oct 03 '18 at 10:22
  • @AntonBjerg Yes. Maybe try this one: https://learnappmaking.com/pass-data-between-view-controllers-swift-how-to/#forward-segues – Dris Oct 03 '18 at 12:09

0 Answers0