• Complain

Languedoc - Build iOS Database Apps with Swift and SQLite

Here you can read online Languedoc - Build iOS Database Apps with Swift and SQLite full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. City: Berkeley;CA;United States, year: 2017, publisher: Apress, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Languedoc Build iOS Database Apps with Swift and SQLite
  • Book:
    Build iOS Database Apps with Swift and SQLite
  • Author:
  • Publisher:
    Apress
  • Genre:
  • Year:
    2017
  • City:
    Berkeley;CA;United States
  • Rating:
    4 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 80
    • 1
    • 2
    • 3
    • 4
    • 5

Build iOS Database Apps with Swift and SQLite: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Build iOS Database Apps with Swift and SQLite" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Languedoc: author's other books


Who wrote Build iOS Database Apps with Swift and SQLite? Find out the surname, the name of the author of the book and a list of all author's works by series.

Build iOS Database Apps with Swift and SQLite — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Build iOS Database Apps with Swift and SQLite" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Kevin Languedoc 2016
Kevin Languedoc Build iOS Database Apps with Swift and SQLite 10.1007/978-1-4842-2232-4_1
1. Creating the Objective-C Wrapper
Kevin Languedoc 1
(1)
Montreal, Canada
Electronic supplementary material
The online version of this chapter (doi: 10.1007/978-1-4842-2232-4_1 ) contains supplementary material, which is available to authorized users.
Creating a wrapper for a C library is a very easy task with Swift, as the language was designed for interoperability with Objective-C and C, as well as for C++ language. Although this chapter focuses on using the SQLite C API with Swift, you could easily do the reverse and call Swift from these languages. This chapter shows how to create an Objective-C wrapper around the SQLite C API, which can then be interfaced through Swift. This method can be replicated with other C libraries.
In this chapter, Im going to show you how to do the following:
  • Create a Swift project
  • Add the SQLite 3 C API library to the project
  • Create a bridge header file to interface with the C API
  • Configure the Swift compiler
  • Create a DAO class to handle the execution for queries
Getting Started
Before getting to the bridge, I think it is important to mention the tools that are needed for this book and also for iOS application development in general. All the iOS code for this book is produced through Xcode 8.0 at the time of this writing. I am also using Swift 3.
If you are planning on developing Swift iOS apps for this book or in a production environment, your only choice is Xcode on OSX. Some will argue that Swift can compile and run on Linux also. While this is true, Xcode cannot, and you need Xcode to develop iOS, TVos and OSX apps. You will also need an Apple Developer account. For the development in this book, you can get by with the free edition, but to provision and deploy you will need an Apple Developer license, which you can get though Apple Developer website.
I will also use SQLite Manager in Firefox to create SQLite databases in chapters ; otherwise, all development, including creating SQLite databases, will be done in Xcode.
Xcode can be installed for free through the OSX App Store, which is accessible uniquely on a MAC OSX. While you can purchase a copy of OSX through an Apple store, and it can be installed on a virtual machine, the OSX App Store will only work on a real OSX machine.
Installing Xcode is very easy. Once you select it in the App Store, it is installed automatically on your OSX machine. When you install Xcode, the SDK (for Swift/Objective-C) is also installed. You can install more tools through Xcode. Under the Xcode menu, select Preferences and then Components.
The SQLite library is already included in the iOS SDK, and this is the version that I will be using throughout this book. You can download and install SQLite from the SQLite site, which has extra APIs such as the JSON extension, but this is out of the scope of this book. You can also download and use Swift SQLite frameworks that have been created as wrappers over the SQLite C API. However, I wont be using them in this book, as I find the C API very easy to work with on its own.
Other than Xcode and an Apple OSX computer, you only need Firefox SQLite Manager, which can be downloaded and installed from Mozilla. The SQLite Manager is installed from the Addon marketplace in Firefox.
Lets get started.
Creating the Swift iOS Project
To work with SQLite 3 in iOS Swift applications, you need a bridge header file to interface with the SQLite C API. In fact, this interface is applicable to all interfaces between Swift and Objective-C, C, or C++.
Open Xcode and create a new project from the launchpad. For this project, we are building a SQLite Database Manager app that will allow a developer to connect to a SQLite database. The app will also provide functionality to add or modify tables, views, indexes, and triggers. Finally, one will also be able to insert, update, and select data from the database.
To build this app, select the Master-Detail iOS template from the list of templates under the iOS Application heading. Name the iPad app SQLite Mgr and create it. Figure shows an example of the Master-Detail template under the iOS Application heading. After selecting the template, move to the next page to fill in the app details. This template provides a great classic layout for building iPad apps and takes advantage of the extra screen real estate. The template has a view on the left-hand side that acts as an index by default, although you could replace the UITableView with another view. The view on the right-hand side provides an expansive window to display input forms or other app details, including web pages and tables or other view controllers.
Figure 1-1 Master-Detail iOS Application template For this reference app - photo 1
Figure 1-1.
Master-Detail iOS Application template
For this reference app, we will use some of the default design elements that are included with the template, namely the UITableView in the MasterViewController . For the DetailViewController , we will develop a new UI layout.
Figure illustrates the information needed to name and set up the basic app structure. The Organization Name is used throughout the project and documentation, such as for the copyright notice. The Organization Identifier is used to create part of the Bundle ID for the App Store and to identify the app in iTunes Connect, for instance.
Figure 1-2 Enter the app name and other required information Create the Db - photo 2
Figure 1-2.
Enter the app name and other required information
Create the Db Mgr Project Structure
The project structure of a Swift app is identical to that of an Objective-C structure in Xcode. As a matter of preference, I like to organize my app objects into logical groups. So, we will create groups for views, models, and controllers, as well groups for libs, bridge, and utils. The first three are to group the files related to the MVC design pattern. The last two will group the SQLite 3 library and some helper classes that we will use for the app that dont fit in the other groups.
To add files to the project, right click on the group heading and use the context menu to select the Add New File command, which will insert the new file that we will create under that header. You can also add a new file from the menu in Xcode and select from the dialog box for naming the file the group where you want to file to be created.
Adding the SQLite 3 Library
Add the SQLite 3 library to the project as you would normally do through the Linked Libraries and Frameworks. Select the project root in the navigator and scroll down to the Linked Libraries and Frameworks from the General sheet of the Project Properties page, which appears in the main window.
Figure provides an example of the Search dialog box used to add libraries to an Xcode project. Click on the + sign to open the Search window and type "Sqlite3." You will get two results; one of the selections is the library and the second is a link to the library. Select the libsqlite3.tbd file and click the Add button to add the library to the project.
Figure 1-3 Add the SQLite library to the project In the project explorer - photo 3
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Build iOS Database Apps with Swift and SQLite»

Look at similar books to Build iOS Database Apps with Swift and SQLite. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Build iOS Database Apps with Swift and SQLite»

Discussion, reviews of the book Build iOS Database Apps with Swift and SQLite and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.