True, SQLite isn’t the only way to persist data on iOS. Mkdir -p ~/Documents/Shared\ Playground\ Data/SQLiteTutorial Run the following command in Terminal to create the data directory for your playground: Your playground will need somewhere to write SQLite database files on your file system. This ensures all statements execute successfully as you move through this SQLite with Swift tutorial. You might also see a destroyPart1Database() call at the top of the page you can safely ignore this, since the database file is destroyed each time the playground runs. This means it will only execute when you explicitly invoke the execution by hitting the “Play” button. Notice that your Playground is configured to run manually instead of autmatically: This binary contains all the functionality for the SQLite code you’re going to write in this tutorial. Note: The project is packed up in an Xcode workspace since it uses the SQLite3 dependency as an embedded binary. This will let you write abstraction APIs for your apps so that you can (mostly) avoid the pain of working with the SQLite C APIs! :]įinally, I’ll briefly cover the popular open source Swift wrapper SQLite.swift to give you a basic understanding of how underlying frameworks work within a wrapper. Throughout this SQLite with Swift tutorial, you’ll learn how to perform the following database operations:Īfter learning how to perform these fundamental operations, you’ll see how to wrap them up in a more Swift-like manner. In fact, if you’ve used Core Data before, you’ve actually already used SQLite since Core Data is only a layer on top of SQLite that provides a more convenient API. But how do you store it effectively - and efficiently?įortunately, some great minds have developed solutions for storing structured data in databases and writing language features to access that data. In many cases, this comes in the form of data structures. In the world of software development, it doesn’t take long before you need to persist app data. This SQLite with Swift tutorial shows you how to work with the popular database platform from within Swift. Curious about using the SQLite C APIs from Swift? Then read on…
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |