且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何存储用户输入的详细信息并返回ios?

更新时间:2023-12-04 09:03:28

您要保持用户Info持久化(1)还是您需要此数据来表示它并发送到电子邮件(2)?

1.如果您需要保存用户信息在持久存储中使用Core Data,您必须使用您的属性(名称,中间名,姓氏,用户名,电子邮件,重新输入电子邮件ID,电话,状态,地址,地点和PIN码)创建名为可以是字符串类型。比在编辑器选项卡的帮助下,您应该为您的实体创建NSManagedObject子类。比在你的VC与textFields,你需要填写这些数据的属性的User实例并保存。而且你可以检索你想要的和显示给用户。

2.如果你需要用户信息只是显示和发送到电子邮件,你可以使它更简单,使用NSUserDefaults例如:



//保存

  [[NSUserDefaults standardUserDefaults] setObject:textFieldName.text forKey: @名称]; 

//取得资料

  [[NSUserDefaults standardUserDefaults] valueForKey:@name]; 

或者如果需要始终保留此信息,启动会话 - 只需通过textFields的文本属性值设置ViewControllerWhereYouWantToPresentInfo的公共属性。


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,Localityand 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?

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.