简体   繁体   English

iPhone-保存用户数据-sqlite

[英]iphone - save user data - sqlite

I have a situation where the user enters a screen and fills some data and when the user leaves the application or click save. 我遇到一种情况,用户进入屏幕并填充一些数据,并且当用户离开应用程序或单击“保存”时。 I want to save the information. 我要保存信息。 In most of the textfields the data is pre-populated from the Web service data.In one text field it has a UIpickerview from which user and choose an option. 在大多数文本字段中,数据都是从Web服务数据中预先填充的。在一个文本字段中,它具有一个UIpickerview,用户可以从中选择一个选项。 I am saving all the data in SQLite database. 我将所有数据保存在SQLite数据库中。 based on the date and time. 根据日期和时间。 Next time the user visits the saved screen i need to show the saved information. 下次用户访问已保存的屏幕时,我需要显示已保存的信息。 Now the data will be from the sqlite db and not web service. 现在,数据将来自sqlite db而非Web服务。 In this case how will show the UIPickerview data. 在这种情况下,将如何显示UIPickerview数据。 Because only the user chosen data is saved in the DB. 因为只有用户选择的数据才会保存在数据库中。 How can i solve this. 我该如何解决。 Any help is appreciated. 任何帮助表示赞赏。

Thanks 谢谢

You are receiving data from web service in which you must be having some unique field. 您正在从Web服务接收数据,其中必须包含一些唯一字段。 Store that field into the local database . 将该字段存储到本地数据库中 When you load the screen compare that unique id received from the web to the local database . 加载屏幕时,将从Web接收到的唯一ID与本地数据库进行比较 If that Unique ID is not available in local that means user is visiting first time otherwise not. 如果该唯一ID在本地不可用 ,则意味着用户是第一次访问。

Hope it helps. 希望能帮助到你。

You have to know where is your UIPickerview data, to show all picker value. 您必须知道UIPickerview数据在哪里,才能显示所有选择器值。

And you can save your selected data with NSDictionary type(or object...), that has key selected(BOOL). 然后,您可以使用NSDictionary类型(或对象...)保存选定的数据,该数据具有选定的键(BOOL)。

So next time you read data from DB, You have key to know what value you selected. 因此,下次您从数据库读取数据时,您就有钥匙知道所选的值。

Hope it helps.... 希望能帮助到你....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM