How to Use SQLite to Manage Data in iOS Apps

Among the numerous applications existing on the App Store today, it would be hard for someone to find more than a few of them that do not deal with data. Most of the apps handle some sort of data, no matter in what format they are, and always perform some actions upon it. There are various solutions offered to developers for storing and managing data, and usually each one of them is suitable for different kind of applications. However, when working with large amount of data, the preferred method it seems like a one-way path: That is the use of a database.

Indeed, making use of a database can solve various kind of problems that should be solved programmatically in other cases. For programmers who love working with databases and SQL, this is the favorite data-managing method at 90% of the cases, and the first think that crosses their minds when talking about data. Also, if you were used to working with other databases or database management systems (DBMSs), then you’ll really appreciate the fact that you can keep applying your SQL knowledge in the iOS platform as well.

The database that can be used by apps in iOS (and also used by iOS) is called SQLite, and it’s a relational database. It is contained in a C-library that is embedded to the app that is about to use it. Note that it does not consist of a separate service or daemon running on the background and attached to the app. On the contrary, the app runs it as an integral part of it. Nowadays, SQLite lives its third version, so it’s also commonly referred as SQLite 3.

sqlite-database

[Read more...]

A Beginner’s Guide to Optionals in Swift

Swift was announced three weeks ago. Since then, I have been reading the Swift’s official guide and playing around with it in Xcode 6 beta. I started to love the simplicity and syntax of Swift. Along with my team, I am still studying the new language and see how it compares with Objective-C, a 30-year-old programming language. At the same time, we’re working really hard to see how we can teach beginner and help the community to pick up Swift effortlessly.

Two weeks ago, we covered the basics of Swift. In coming weeks, we’ll write a series of tutorials to cover a number of new features in Swift. This week, let’s first take a look at optionals.

swift-optionals-featured

[Read more...]

Using iAd to Display Banner Ad in Your App

So, you are about to start developing the next super app, you have everything planned and designed, but there’s still one last thing you haven’t made your mind up about; how to make some earnings out of it! Well, there are two options apart from offering it completely free: Either to make it a paid app where your potentials users should pay to download it, or make it a free app, add some advertisements, and earn a revenue from the ads.

Today’s trends show that it’s more possible for users to download free apps, instead of paid ones. They will pay for an app if it really worths it, or if it’s super famous and have received good rating. So, having that in mind, you decide to make your app a free one, and integrate advertisements in it. To do so, you have various services to pick from in order to display ads, and one of them is the iAd Network provided by Apple. Undoubtably, you have already concluded even from the tutorial’s title that the today’s topic is about how to use iAd advertisements, but before we see all in action let’s see some introductory stuff.

Deciding about the kind of your application (paid or free) before starting the actual implementation is really important, as it affects your work directly. For paid apps, there’s no need to do anything particular, however for free apps it’s necessary to define where the ads will appear, and setup your interface accordingly. Speaking of position, ads should be placed either to the top or the bottom of your view controller. If your app does not contain a tab bar, then ads should be placed at the bottom of the screen, otherwise at the top. Note that if you display ads anywhere else in the view, then the Human Interface Guidelines are breached and Apple will reject it with no second thought.

iad-featured
[Read more...]

Getting Started with Swift: A Brief Intro to the New Programming Language

Along with the announcement of iOS 8 and Yosemite, Apple surprised all developers in the WWDC by launching a new programming language called Swift. At AppCoda, we’re all excited about the release of Swift. We enjoy programming in Objective-C but the language has showed its age (which is now 30 years old) as compared to some modern programming languages like Ruby. Swift is advertised as a “fast, modern, safe, interactive” programming language. The language is easier to learn and comes with features to make programming more productive. It seems to me Swift is designed to lure web developers to build apps. The syntax of Swift would be more familiar to web developers. If you have some programming experience with Javascript (or other scripting languages), it would be easier for you to pick up Swift rather than Objective-C.

If you’ve watched the WWDC keynote, you should be amazed by an innovative feature called Playgrounds that allow you to experiment Swift and see the result in real-time. In other words, you no longer need to compile and run your app in the Simulator. As you type the code in Playgrounds, you’ll see the actual result immediately without the overheads of compilation.

swift-playground

At the time of this writing, Swift has only been announced for a week. Like many of you, I’m new to Swift. I have downloaded Apple’s free Swift book and played around with Swift a bit. Swift is a neat language and will definitely make developing iOS apps more attractive. In this post, I’ll share what I’ve learnt so far and the basics of Swift.
[Read more...]

First Time App Developer Success Stories Part 3: Am I Too Late to Learn iOS Programming

Am I too late to start learning iOS programming? Simply do a search on Google or Quora. You’ll see lots of discussions around the web. The mobile market has created tons of opportunities and possibilities. It’s amazing you can turn an idea into app that millions of people use. I’ve met a lot of people who love to create apps but think coding is difficult and it’s too late for them to learn to code.

It’s never to late. It’s the lack of determination and drive that keep you from learning programming. Some time ago, we shared the first and second parts of app developer stories. In part 3 of the series, we featured even more app developers to share their success stories. The ages of these first-time app developers range from 15 to 68 years old. Yes, you read it right. Robert Chalmers, one of the featured developers, is 68 years old! Though Robert got years of experience, it’s amazing he still keeps learning new programming language. I couldn’t imagine if I would still learn programming at that age. Rémy Spehler, who is a doctor by profession, started from zero programming experience to published his first app at the age of 58. The design of their apps is elementary and may not catch your attention. But they set a great example showing that everyone can learn iOS programming and build apps regardless of age.

first-time-app-showcase-3

I haven’t highlighted all the developers here but all of the stories are truly inspiring. Read on and check out their success stories.

[Read more...]

Integrating Facebook Login in iOS App – The Manual Way

In my previous tutorial, I presented an easy and fast way to implement the login with Facebook feature. Based on the FBLoginView class, I demonstrated how logging in and out from Facebook can be done in really a few minutes with the assistance of a predefined login button. In this tutorial we’ll do the exact same thing, but this time we won’t use any automatic solution. Instead, we will implement every part of the login process manually and we’ll see in some detail level how everything works when connecting to Facebook. That’s a useful knowledge to have, as there are many cases that the default login view we saw in the last tutorial isn’t handful at all.

Before we start programming, it is necessary to present some basic terms, so you’ve got an idea about the whole process. The first important thing you should know, is that after a successful login with Facebook the app receives an access token. This is a unique key, that allows to perform requests and exchange data with Facebook in a secure fashion, without having to authorize the app all the time. One could say that the whole login hassle happens just to get that access token. Once received, and depending on the permissions your app asks for, you can freely get and send data.

facebook-login
[Read more...]

Introduction to UIActionSheet and UIPopoverController

All mobile applications, no matter what they are about, they have one common and obvious characteristic: They offer interaction, which means that they are not static, but require input or actions needed to be taken by users from time to time in order to function properly. One quite usual behavior, is the ability to provide ways that allow users to make choices or take decisions where it’s needed, and ultimately act that way on the applications’ data or functionalities. iOS SDK provides a pre-made action-taking view controller, the UIActionSheet.

Action sheets consist of a really convenient and fast way to display a bunch of options that the user should select from, and it is widely used in great number of applications. Its disadvantage though is that it adopts the iOS’s look and feel without being able to be graphically modified, therefore it might not fit to applications with customized GUI.

Beyond action sheets, another very important and cool tool designed especially for the iPad, is the UIPopoverController. A popover controller is actually a container which is used to display content on top of another content. What makes it unique is the fact that it can be displayed almost everywhere around the screen of the iPad, but usually it’s shown near to the button that caused its appearing with a nice arrow pointing to the button’s direction. iOS by default encloses action sheets in popover controllers on iPad, but they can also be manually created for custom content.

uiactionsheet-featured

Before we begin working with those two view controllers, let’s do some more talking about them in order to get to know their basics, and then we’ll proceed on how to use them in projects. So, let me start by telling that both the UIActionSheet and UIPopoverController exist to serve the same purpose, and that is to provide a quick way for presenting content to the user. This content can be either a button-based menu (action sheet), or anything else originating from a view controller (popover controller). Undoubtably, they are both pretty useful tools, and everyone developing for iOS should master both of them. Their great difference lies to where each one is used, and that’s the essential fact you should be aware of: An action sheet can be used on any iOS device (iPhone, iPad), but a popover controller can be used only on iPad, as I have already said.
[Read more...]

iOS Programming 101: How To Create Swipeable Table View Cell to Display More Options

When iOS 7 was first released, one of the many visual changes that particularly interested me was the swipe-to-delete gestures in the Mail app. By now you should be very familiar with the feature. After you swipe a table cell, you’ll see the Trash button, plus a new button named More. The More button will bring up an action sheet that shows a list of options such as Reply, Flag, etc.

I thought it’s a great feature to provide additional options for manipulating a table record. However, as you know, Apple didn’t make this feature available to developers in iOS 7. You can only create the swipe-to-delete option in table cell. The More feature is only limited to the stock Mail app. I have no idea why Apple keeps such great feature to its own app. Fortunately, some developers have created free solutions (such as UITableView-Swipe-for-Options, MCSwipeTableViewCell) and made them available freely.

In this tutorial, I’ll use SWTableViewCell and see how to implement swipe-to-show-options feature in your app. SWTableViewCell is pretty to easy to use. If you understand how to implement UITableView, you shouldn’t have any problem with SWTableViewCell. On top of that, it supports utility buttons on both swipe directions. You’ll understand what it means in a minute.

Swipeable UITableViewCell

Let’s get started and build our demo app.
[Read more...]

Understanding Git Source Control in Xcode

During an application development process, a quite significant part is the way developers manage to keep track of the changes been made over time. It really consists of a necessary need to be able to store and handle copies of working code versions in various stable stages, and revert back to them when bugs or problems arise. Even more, when a number of programmers work at the same project, keeping track of all changes is a one-way path. Fortunately, developers don’t have to discover their own way to do all that, as there are special software solutions, called Version Control Systems.

A version control system, or in other words a revision control system, is actually a (software) mechanism that is capable of monitoring changes performed to code files over time and storing them for future reference. Besides that, it can also save extra essential data, such as the developer who made the changes, when did they happen, what was actually modified, and other kind of historical and not only data. Moreover, such a system provides the ability to compare various versions of the code, revert to a previous version of either specific files or a whole project if needed, and eventually implement a bug-free product by tracking down any malicious code.

git-source-code

Using a version control system, developers can work on different paths of a project, commonly named branches, and when their piece of project is ready, everything is put together so the final release of the application can be built. This process is called merging, and it consists of a special characteristic of version control systems. Actually, that fashion of work is mandatory in teams of developers and software companies, where each one if responsible for a project’s part, and at the end everything must be gathered up and put in one place.

For single developers it is not required to use a version control system, however is highly recommended, as with it’s much more easier to track down bugs or going back to stable and working versions of code, once a dead end appears or for some reason everything is messed up. The truth is that a great number of lone-rider programmers, especially the new ones, do not use such a system at all, and is common to manually keep copies of their projects when they are about to add new features or generally modify them. That’s a really bad habit, as a source control system does all that much better and efficiently, providing at the same time all the extra capabilities previously described.
[Read more...]