rose lovely rose lovely - 6 months ago 13
iOS Question

How to Store User Entered Details and Get It Back in ios?

How to

Store
user entered details and
Get it Back
in ios?



  • I had Following
    TextFields
    :

  • UserName
    ,
    Email
    ,
    Re-enter Email id
    ,
    Phone
    ,
    State
    ,
    Address
    ,
    Locality
    and
    Pincode
    .

  • I want to
    store
    this Details in
    Current viewController
    locally and
    display
    this details in
    Next ViewController
    ....

  • How many Ways
    I can
    Store
    and
    Fetch
    the Details, Does anyone know where I can find more information about this?


Answer

Do you want to keep user Info persistent(1) or you need this data just to represent it and send to email(2)?
1.If you need to save user info in persistent store using Core Data you have to create entity named 'User' with your attributes (Name, middle name , lastname, username,email, re-enter email id, phone, state, address,locality and pincode) - all this fields can be A String type. Than by the help of 'Editor' tab you should create NSManagedObject subclass for your entity. Than in your VC with textFields you need to fill these data for properties of User instance and save it. And than you can retrieve where you want and display for user.
2.If you need user info just to display and send to email you can make it simpler by using NSUserDefaults for example:

//to save

[[NSUserDefaults standardUserDefaults] setObject:textFieldName.text forKey:@"name"];

//to get data

[[NSUserDefaults standardUserDefaults] valueForKey:@"name"];

Or if there is a need to keep this info all the time and you need it just for one app launch session - just set ViewControllerWhereYouWantToPresentInfo's public properties by text property value of textFields.