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
Alexander Certosimo
1,774 PointsQuestion on how to implement something for app
hey all,
So i have something i was thinking about, but i cant think of a solution myself so i figured i would ask for help. If i had a view that would segue to another view so a user could input some data that would be stored in an array as well as NSuserdefaults, what could i do that would give the user access to their inputted data so that if they wanted to delete or edit it? i cant figure out how to layout their inputted data in a simple way that they can see it and change/delete it when need be. Should i be using a table view for that? Any input is appreciated
1 Answer
Gabe Nadel
Treehouse Guest TeacherWell, it depends how much information you want to display. If it's not too many different chunks of text, you can create a few UITextViews and then display their saved value by using myTextView1.text. If you set the textViews to editable, then they will be able to change the values they see. Then implement some method to save those values to NSUserDefaults whenever they click a "save" button, or swipe away or whatever you think is best.
(For very short pieces of text, you can also use UILabels rather than UITextViews)
Alexander Certosimo
1,774 PointsAlexander Certosimo
1,774 PointsGabe,
Thanks for the informative response as always. So the amount of text is going to depend on the user. I want the user to input questions, that they can then have come up one at a time in another view simply with a button. So i guess unless i cap the amount of questions they can input, i wont know many one user has. I think thats why i stuck with providing some list of everything they input for easy editing or deleting . Since UItextview is scrollable though, that would still work no matter how much text is input by the user anyway, right?
Gabe Nadel
Treehouse Guest TeacherGabe Nadel
Treehouse Guest TeacherWell, the issue with listing ALL the questions in a single scrolling view is that someone could really easily mess up the spacing/formatting or just accidentally delete the whole thing.
It sounds like using a table view would be a good way to organize it, but perhaps you want to create your own custom cell that contains a UITextView which you populate with just that questions text.
If you want to get a good jumpstart on this project, you might want to use some of Apple's sample code, so the TableView stuff is already built and you can just focus on customizing it for your needs.
Good Luck!
Alexander Certosimo
1,774 PointsAlexander Certosimo
1,774 PointsGabe,
Thank you. That sounds good. Since i have four different views that would have their own set of questions, Do you think it would be most efficient to have one table view with four four sections for each of those views and just cap the amount of rows for each section rather than doing a separate tableview for each main view? I think that makes more sense and cuts down on some work.
Is Apples sample code located on their website?
Gabe Nadel
Treehouse Guest TeacherGabe Nadel
Treehouse Guest TeacherIt's hard to answer your first question without knowing more about the project, how many questions folks would enter, the total amount of potential scrolling, etc...
as for the sample code, you can go here and then search for sample code for topics that interest you - like UITableView
Alexander Certosimo
1,774 PointsAlexander Certosimo
1,774 PointsGabe,
Sorry i didnt reply sooner. So my thoughts for the questions was to have a single tableview with 4 sections and then have a fixed amount of 10 rows in each section. This would limit the user to 10 questions for each section i believe. And based on your advice i will use custom cells with a uitextview in each row that would hold one question. This should give the user the ability to edit/delete each of their questions within each specific row. I think this is the most efficient way to organize everything. Is my thinking on the right track?