34,333
edits
Changes
no edit summary
[[Image:xcode_6_add_git_repository_dialog.png|Adding the FMDB Git repository to an Xcode project]]
Figure 44-1
[[Image:xcode_6_fmdb_source_files.png|Adding the FMDB source files to the project]]
Figure 44-2
Shift-click on the first and last of the files in the fmdb folder to select all of the .h and .m files in the navigator panel and drag and drop them onto the Database project folder in the Xcode window containing the Database project. On the options panel click on the Finish button. Since these files are written in Objective-C rather than Swift, Xcode will offer to configure and add an Objective-C bridging header file as shown in Figure 44 3:
[[Image:xcode_8_ios_10_sqlite_bridging_header.png|Generating the Objective-C bridging header]]
Figure 44-3
[[Image:ios_10_sqlite_ui.png|the user interface for the SQLite example app project]]
Figure 44-4
• If the file does not yet exist the code creates the database by creating an FMDatabase instance initialized with the database file path. If the database creation is successful it is then opened via a call to the open method of the new database instance.
• Prepares a SQL statement to create the contacts table in the database and executes it via a call to the FMDB executeStatements method of the database instance.
• Closes the database
[[Image:ios_8_sqlite_demo_running.png|The iOS exampel SQLite app running]]
Figure 44-5