Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


shane reichefeld
shane reichefeld
Courses Plus Student 2,232 Points

Swift App Question

OK so i have 2 views, view1 and view2. in view1 there are 3 textfields and in view2 there are 3 labels. I need the numbers entered in the 3 textfields to be saved so its in the app and then i need it to be put into view2 and set to the labels. Also i need it so if the textfield enters a second+ number for it to add it to the last number so they keep adding up.

How would i do this? I tried NSUserdefaults and trying to move it to another view but it doesnt work.

1 Answer

If you need to save the data on disk, you can try Core Data. (Create an app with a core data stack or add one.)

  1. Create an entity
  2. Add three attributes (one for each textField Value)
  3. Save the values
  4. Fetch the values (make sure to use the same MOC in the second view)