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

iOS

Objective-c program

Hello everyone,

I'm trying to understand a concept more than ask for a code. I'm trying to make an application that asks a user to write his email and in another field his password and that would be save in a file on the device to be retrieved later upon request, please let me know what you would do.

Thanks in advance Moosie.

2 Answers

There are 3 or 4 main ways off the top of my head that this could be done, and then depending on which you choose there is probably about a 100 ways to implement that. So roughly speaking with a simple example you might be able to find here in the Treehouse videos:

  1. Set up two UITextFields (are you using Interface Builder?)

  2. Some way to capture the .text in those views i.e. a button saying submit via properties, etc.

  3. Save it via NSUserDefaults, Archiving, or Core Data.

4.Provide a way to retrieve that info... maybe a UIViewController with a retrieve button, or a UIViewController with a custom gesture to present the data back to the user, or maybe they shake the device after pressing a button? Lots of ways really.

-5. To get the info back to user is again depending on what you are using to save or persist that data in step 3.

All the ways in step three have methods in Cocoa Touch to do this and Amit explains most of them in the course. You will also need to dismiss the keyboard at some point which is also explained.

If you re watch the iOS courses with that question in mind you will probably see multiply ways of doing what you are wanting to do. Just think every time you see a new lesson ask if that applies to what you are wanting to do.

Off the top of my head the NSUserDefaults example is explained with the "Setting Bundle" video if I recall, you don't have to use the Setting Bundle part of the video to make use of NSUserDefaults. You can use it for many things.

I hope that helps? If you have a specific design or implementation in mind then maybe someone can get a more specific answer to you. Like are you planning on making this happen with Interface Builder? Do you want to data encrypted? Is this data the main screen the user sees at launch?

Thanks a lot for the detailed reply Joe, I will be playing around with Xcode and I will try what you described and keep you updated with what I do. And yes I'm using InterfaceBuilder but for buttons and images I will be using photoshop. Once again thanks for the help.