官术网_书友最值得收藏!

  • Learning SQLite for iOS
  • Gene Da Rocha MSc BSc (Hons)
  • 491字
  • 2021-07-16 12:32:41

iOS with SQLite

Out of the hundreds of thousands of apps in all the app stores, it would be difficult to find the one that does not require a database of some sort to store or handle data in a particular way. There are different formats of data and datafeeds, but they all require some sort of temporary or permanent storage. A small amount of data may not be applicable, but a medium or large amount of data will require a storage mechanism, such as a database to assist the app.

Using a database such as SQLite with iOS will enable developers to use their existing skills to run their DBMS. For SQLite, there is a C-library that is embedded and available to use with iOS with the Xcode IDE.

Apple fully supports SQLite, which uses an include statement as a part of the library call, but developers can also use FMDB, which is a cocoa/objective-C wrapper around SQLite.

A few advantages of SQLite are that it is fast, lightweight, reliable, uses existing SQL knowledge, is supported by Apple on Mac OS and iOS and by many developers, as well as being integrated without much outside involvement.

The SQLite 3 library is under the general tab once the main project name is highlighted on the left-hand side of the page. Then, at the bottom of the page, within Linked Frameworks and Libraries, click on the + for a modal window to appear. Enter the word sqlite and select the libsqlite3.dylib library, as shown in the following screenshot:

In effect, it is the C++ wrapper, called the libsqlite3.dylib library, within the framework section that allows the API to work with SQLite commands.

Before any SQL processes can take place, the database should be opened and ready for querying, and, upon the success of data retrieval, the constant called SQLITE_OK should be set to 0.

Once the C++ wrapper is used and the access to SQLite commands is available, it is an easier process to use SQLite with iOS.

Tip

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  • Log in or register to our website using your e-mail address and password.
  • Hover the mouse pointer on the SUPPORT tab at the top.
  • Click on Code Downloads & Errata.
  • Enter the name of the book in the Search box.
  • Select the book for which you're looking to download the code files.
  • Choose from the drop-down menu where you purchased this book from.
  • Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux
主站蜘蛛池模板: 丹棱县| 开原市| 龙游县| 甘谷县| 施秉县| 任丘市| 莲花县| 曲阜市| 宁国市| 安阳县| 青川县| 封开县| 常熟市| 囊谦县| 尚志市| 疏附县| 阿坝县| 武乡县| 萨迦县| 孝感市| 东山县| 新丰县| 潮安县| 咸阳市| 同仁县| 化隆| 定边县| 东至县| 尼玛县| 板桥市| 科技| 吉木乃县| 新平| 定南县| 威海市| 安徽省| 壶关县| 石屏县| 固原市| 石狮市| 泸水县|