Sqlite数据库应用程序
我想在委托文件和代理文件中使用相同的数据库对象自定义创建的数据库头文件的控制器文件,其中包含 Sqlite3 类型的对象三种方法 像 OpenDB 和创建表&插入数据。
我现在只是 iPhone 编程的初学者,所以请帮助我
I want to use same database object at Delegate file & Controller File of Custom Created databse header file which Contains object of type Sqlite3 & thee methods
like OpenDB & CreateTable & InserData.
i m right now just beginner in iphone programming so, pls Help me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应用程序委托文件就像一个全局文件,您只需在应用程序委托中导入自定义创建的数据库头文件,并创建自定义创建的数据库头文件的对象,假设文件名是dbOperations.h,
在应用程序委托中
导入它并创建它的对象,然后,执行属性,合成,仅此而已。
在任何视图控制器中,您只需要导入“appDelegate.h”文件并使其视图中的对象确实加载,如
objAppdelegate = [[UIApplication sharedApplication]delegate];
访问 dbOperations.h 文件的所有方法和成员
您可以通过objAppdelegate.objdbOperations
。你在 appdelegate 中放入的任何内容都将保持对整个 app 、所有 viewController 和所有类的共享和通用。
您的 createDatabase 方法应该像这样,并在您的应用程序完成 appDelegate 文件的加载方法时调用此方法。
并像这样触发sql查询,在上面的代码中@“database.sqlite”是你的数据库文件名。
app delegate file is like a global file , you just import the your Custom created database header file in app delegate , and create the object of Custom created database header file , assuming the file name is dbOperations.h
in app delegate
import it and create its object, then , do property , synthesize and that's all.
in any view controller you just need to import your "appDelegate.h" file and make its object in view did load like
objAppdelegate = [[UIApplication sharedApplication]delegate];
and you may access your all methods and members of dbOperations.h file by
objAppdelegate.objdbOperations .
whatever you put in appdelegate will remain shared and common to entire app , all viewControllers and all classes.
your createDatabase method should be like this, and call this method when your application did finished loading method of appDelegate file.
and firing sql query like this fashion, in above code @"database.sqlite" is your db file name.