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 trialTom Coomer
1,331 PointsAdding names then displaying in label
I am making an iOS app in which I need the user to be able to add a multiple names. These names will then be stored and displayed 1 at a time in a label. When the device is shaked the label will then display the next name in the list. I have looked into Core Data and NSArrays but i don't know the best way of doing this?
Thanks
5 Answers
Pavel Palancica
6,535 PointsHey Tom,
If you only need those names to be stored for a short period of time (the app's execution time, for instance) use NSArray-s, if you want the data to persist, even if you close the app, then you should save it with Core Data, or, more simple, with NSUserDefaults.
Hope it helped you somehow :)
Tom Coomer
1,331 PointsThanks for the help.
Can the names be put in by the user using a text field and then edited at a later date?
Thanks
Pavel Palancica
6,535 PointsNot sure if I understand correctly you question, but I think you want to create the names during the app's execution, right? Yes, it's possible. Make sure you use NSMutableArray for that.
Tom Coomer
1,331 PointsIf I store the list in an array will the list be deleted if the app is in the background whilst multitasking?
Pavel Palancica
6,535 PointsYes, it should be in memory and available for using the data inside it, even if the app goes into background (if using multitasking).