以编程方式将textField的文本添加到sqlite数据库 [英] Add Programmatically added textField's text to sqlite database

查看:163
本文介绍了以编程方式将textField的文本添加到sqlite数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的xcode项目中实现了sqlite。它从UITextField获取数据。每次用户单击按钮时,都会以编程方式添加texField。我将重新创建相同的textField。 (如何。)如何将textField的数据输入sqlie文件?



SQLite在终端中创建

I have sqlite implemented in my xcode project. It gets its data from a UITextField. There is a texField that gets added programmatically everytime the user clicks a button. I will be recreating the 'same' textField. (Kind of.) How can I get the textField's data to the sqlie file?

SQLite Created in Terminal

CREATE TABLE myDB(myDBID integer primary key, first text, second text);





目标C



Objective C

NSString *query = [NSString stringWithFormat:@"insert into myDB values(null, '%@', '%@')", self.textView1.text, self.textView2.text];
[self.dbManager executeQuery:query];

//IBAction:
UITextField *text = [[UITextField alloc] initWithFrame:frame];
[self.view addSubview:text];





如何将以编程方式添加的textField文本添加到sqlite数据库?



How can I add the programmatically added textField's text to the sqlite database?

推荐答案

您只能获取数据库中文本字段的文本字符串。如果您有不同数量的文本字段,则必须保存计数,否则应重新创建一些逻辑。



您需要运行在SQLite上查询QUERY
You will only get the text-string of your textfield in the database. If you have a varying count of textfields you must save the count or some logic would should recreated.

You need to run an INSERT QUERY on SQLite.


这篇关于以编程方式将textField的文本添加到sqlite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆