Working With Background Fetch in iOS 7

Among the millions of applications existing on the App Store, there is a great number of them that deals with data fetched from the web. Even more, today that carriers provide constant Internet access through 3G and 4G networks at low cost, these apps seem to grow even more. News, weather and social applications are just some of them. Prior to iOS 7, there was a great disadvantage that was characterizing any app of that kind, and that was the awaiting time that users were facing until their apps got updated with new data taken from online servers every time they were launched. Developers didn’t have enough tools on their hands to counterattack that, or work around it, so they had to figure out tricky ways to download just the minimum possible amount of data and return control back to the user as soon as possible.

However, with the iOS 7 SDK coming things drastically changed thanks to the Background Fetch API, which is part of the new multitasking features that the latest version of iOS supports. When the Background Fetch feature is enabled to an app, the system wakes the app up in the background from time to time and lets it go online to fetch new data with goal to refresh its content. That way, the app is always up to date, and users don’t have to wait any more when they launch it. In other words, it is the tool that all developers have been expecting for a long time in order to have both their apps updated and the users happy. In this tutorial we are going to see how this new cool feature can be embedded into an application, but first let’s have a short look at some important details in order to fully get the meaning of this great API.

Working with Game Center and Game Kit Framework

On App Store, the most popular app category among all is the Games category, something that even Apple accepts as a fact. And how this couldn’t be true, regarding that all or almost all iOS users have downloaded and played one or more games, at least one time? Personally, I’m quite confident that those users who haven’t (still) played a game, are limited from very few to none. There are various kind of game players, from the fanatic ones, until those who play from time to time, as well as numerous kind of games. However, there is one common element, no matter what kind of player each of us is, or what kind of games we like to play: Games are much more interesting when they allow players to achieve goals, or when they allow to compete or play against other players. In iOS (and MacOS), this comes true through the Game Center network Apple provides, and through the GameKit Framework.

Let’s take things from the beginning, and let’s talk a bit about the Game Center. One could describe it as a social gaming network that offers multiplaying features, available for and used from iOS and MacOS users. Achievements, leaderboards, multiplayer gaming are some of those features. It was made available along with the iOS 4.1, and since then it’s been updated with new gaming options.

Understanding Multipeer Connectivity Framework in iOS 7 – Part 2

Editor’s note: In part 1 of the multipeer connectivity series, we gave an introduction of the Multipeer Connectivity Framework and built chat feature of the demo app. The Multipeer Connectivity Framework is one of the many new frameworks introduced in iOS 7. As you can see in part 1, the framework allows developers to easily establish communication between nearby devices and implement features for data exchanging. In part 2 of the series, let’s continue to explore the Multipeer Connectivity Framework and see how we can implement the file sharing feature.

Understanding Multipeer Connectivity Framework in iOS 7 – Part 1

The Multipeer Connectivity Framework is one of the many new frameworks iOS 7 introduces, and it broadens the range of the applications that can be built for the new operating system. Its aim is to enable developers to create applications that will allow devices being in close distance to get connected, simply using Wi-Fi networks or Bluetooth. Great tools are offered for establishing communication between nearby devices, and for exchanging data and other resources without much effort to be required.

Continuing this introduction, it’s necessary to discuss a few more details about the Multipeer Connectivity framework and become more familiarized with it before we see any example of it. First of all, it’s really important to underline that this framework works on nearby devices only, meaning devices that use the same network infrastructure (such as Wi-Fi or Bluetooth), so don’t expect it to work for devices existing in long distance. With Multipeer Connectivity, one device is able to get connected to many other devices and communicate at the same time with all of them. A single device is called a peer. What actually takes place when a connection between two peers is established, is that a Multipeer Connectivity Session gets created, and this session is responsible for managing the whole communication and data exchanging between peers. For multiple devices, multiple sessions can be set up.

Introduction to Objective-C Blocks

In programming, what differentiates a good developer from a great developer is the way each one takes advantage of the programming tools he or she offered by the used language. Objective-C, the official language for developing applications for iPhone, iPad and Mac OS, is a multi-featured one, and as a relative to C, very powerful. New developers have a lot to explore when starting working with it, while advanced programmers have always something new to learn, as there are numerous supported programming aspects. One of them, is the capability to write code using Blocks.

Blocks do not consist of a new programming discovery in Objective-C. They exist in other programming languages too (such as Javascript) with other names, such as Closures. In iOS, they first-appeared in version 4.0, and since then they’ve known great acceptance and usage. In subsequent iOS versions, Apple re-wrote or updated many framework methods so they adopt blocks, and it seems that blocks are going to be partly the future of the way code is written. But what are they all about really?

Using Text Kit to Manage Text in Your iOS Apps

iOS 7 brings along new rules and new Human Interface Guidelines (HIG) that should be followed by all developers. One of those guidelines regarding the all brand-new look and feel, highlights the fact that an application’s interface should not compete with the content, nor distracting users from it, but supporting it in the best possible way. This fact is called deference and, along with some more new HI guidelines, makes clear that Apple with iOS 7 focuses on the content and on the way it’s presented. This is more apparent if we consider the flatten, simple and uncluttered UI, full of white space that makes more room for the content to be displayed. Thankfully, Apple supports developers in their effort to give prominence to their app content, and to text content especially, by introducing a new tool, named Text Kit.

How To Import Contacts Using Address Book Framework

One of the most well-known and most used feature of iPhone devices to all users, developers or not, is the Address Book. For those who use a lot the device as a phone (rather than a mobile mini computer), all important and vital information they need exist in their contacts. Till today, many applications have been developed, and even more can be built that make use the device’s address book data.

Apple makes developers’ life easy, as it provides frameworks that allow to access the address book and deal with its records. Knowing how to work with address book and how to perform some basic tasks (at least), is a knowledge necessary to all developers, as either sooner or later they’ll come in need of integrating address book info into their applications.

How To Scan QR Code Using AVFoundation Framework

iOS 7 brings a wealth of new features that set it apart from all other mobile operating systems. Both major additions and minor improvements have been made, offering developers new or updated frameworks and APIs to work with, and the opportunity to provide single users with a much richer experience.

Xcode 5 Essentials

Xcode 5 is a major step forward for the Apple ecosystem, bringing more possibilities, features, and tools to developers than ever before. With Version 5, Xcode has grown into an extremely powerful IDE. Read this article to learn what’s new!

Multitasking Enhancements

This tutorial will teach you all about the latest multitasking enhancements provided by the iOS 7 SDK. Specifically, you’ll learn about the Background Fetch, Remote Notifications, and Background Transfer Service APIs. Read on!

Working with Google Calendars

In my last tutorial, I showed you how to implement the OAuth 2.0 protocol in order to access Google services. By the end of that tutorial, we had built a fully functional class for accessing Google Services with OAuth 2.0. In this tutorial, I am going to put this class in action by implementing a demo app. Specifically, I am going to show you how to interact with the Google Calendar web service.

Accessing Google Services Using the OAuth 2.0 Protocol

The OAuth 2.0 protocol provides a simple and secure standard that allows third-party applications to access major service providers like Facebook, G+, and Twitter without compromising user passwords. The whole idea revolves around the existence of an access token, something like a unique key that can identify a user in place of a password. Access tokens are obtained by third-party applications after the user successfully authenticates with a web service. The whole process, known as authorization flow, begins when a user enters his credentials into a login window and finishes when the access token is acquired. The access token is usually refreshed from time to time. With this token, there is no need for any of the user’s personal data or password to be transmitted over the web each time that a client application asks for access on behalf of the user.

Creating a Custom Alert View

Welcome to the third and last part of this session, where we’ve created some useful custom views. We’ve implemented a custom text input view, a custom accordion menu, and now we’re going to build a simple custom alert view. Read on!

The custom Alert View is going to be an alternative, simple, and nice alert view that will serve our need to display simple messages to the user. It will mainly consist of the following parts.

  • A label upon which the message will appear.
  • A toolbar below the label.
  • An okay button on the right side of the toolbar.
  • A cancel button on the left side of the toolbar.

The above will reside together into a UIView, and the view will be contained into the main view of the view controller that we’ll build for the purpose of this custom alert view.

Creating a Custom Accordion Menu

This tutorial will teach you how to create a custom Accordion Menu. This animated menu will allow you to collect input from the user in an engaging and streamlined fashion. Read on to learn more!

The accordion menu’s initial position will be at the center of the target view it appears on. When the menu appears, half of it will move towards the top of the target view, while the other half will move towards the bottom of the view, expanding to its full allowed height. During use, both the Y origin point and the height are going to be modified so that the desired effect can take place.

Creating a Custom Text Input View

Developing an amazing application is not a simple job. Traditionally, one of the most difficult aspects of doing so has been creating rich, compelling interfaces. This tutorial will teach you how to build a custom text input view that will help make your own apps shine!

This tutorial is the first in a collection on building custom interface elements. In this tutorial, we will cover customized text input views, and in the next two tutorials we will go over custom accordion menus and alert views.

Working with the NSOperationQueue Class

Multi-tasking prevents apps from freezing. In most programming languages, achieving this is a bit tricky, but the NSOperationQueue class in iOS makes it easy!

This tutorial will demonstrate how to use the NSOperationQueue class. An NSOperationQueue object is a queue that handles objects of the NSOperation class type. An NSOperation object, simply phrased, represents a single task, including both the data and the code related to the task. The NSOperationQueue handles and manages the execution of all the NSOperation objects (the tasks) that have been added to it. The execution takes place with the main thread of the application. When an NSOperation object is added to the queue it is executed immediately and it does not leave the queue until it is finished.

How to show and hide (toggle) UITableview sections on the fly

Hello for one more time!

Some time ago I had written a post about how to use UITableView cells and make them work as a drop-down list. Anyone who had read that post might understood that when working with UITableViews you can do things more than the usual and common ones, and you can go as far as your imagination and the technology let you go. Indeed, when knowing how to work with UITableViews in a more advanced level, then you can create more flexible apps that make your users happier.

So, as you correctly guess, in this post I'm going to work again with the UITableView and to put it in just one, short sentence, I'm going to show you how to display and hide sections on the fly (in the previous post I showed how to display and hide rows of a section).

How to scroll an obscured textfield above the keyboard in combination with UIKeyboard notifications

Hello and welcome back!
For a long time I wanted to write about a specific topic that surely every programmer encounters in his/her programming life. A topic not that difficult, but an important one. That is, how to scroll a textfield to a visible area of the view when it's obscured by the keyboard and how to put it back into its original position, after the keyboard vanishes.

Of course, to accomplish something like that, it's necessary to know when the keyboard is about to appear and when it's about to disappear. Therefore, in this post I'm going to work with two subjects evenly important, combined in the package of one.

Let's discuss about it for a while, beginning from the later one. Every time that the keyboard is going to be shown or to be closed, the system (iOS) sends various notifications to the app regarding each state of the keyboard. For example, such notifications are:

  • UIKeyboardDidShowNotification
  • UIKeyboardDidHideNotification
  • UIKeyboardWillShowNotification
  • UIKeyboardWillHideNotification

How to play audio files using the AVFoundation framework

The topic of this tutorial is about the AVFoundation framework, which is a powerful set of tools that let programmers to work with both audio and video related tasks. In here, I’ll make a small introduction on how to play audio files using the framework, which is the most common task for the majority of the developers.
I should mention that the AVFoundation framework is not the only one letting us playing audio files. There are also:
  • Media Player framework
  • Audio Toolbox framework
  • OpenAL framework
and more.

What we’ll do here: Our goal is to create a simple iOS app with a single view, which is going to have three buttons:
  • Play
  • Pause
  • Stop
No need to explain what these buttons are going to do with our audio file. Additionally, we’ll have a label which is going to inform us about the status of the playback.

How to import contacts from the Address Book - Part 2

Welcome to the second part of this tutorial! At the first part we talked about a couple of things on how to import contacts from the device's Address Book and we developed a demo app to see everything in action. What we really did, was to let us tap on a contact's name, return back to our app and then select specific pieces of information regarding the selected contact, which we displayed on a table view.

In this part what we'll do is going just one step further. We will change a little bit our app and when the user taps on a contact's name a new window will be shown to display specific piece of information. That information will be the e-mail addresses of the contact only. Further more, from the total of the e-mail addresses we'll pick just one by tapping (clicking on the Simulator) on it and that's going to be the e-mail address that we'll display into our table view.

I should also mention that I'm going to base this part of the tutorial on the previous one. That means that I'm going to get the app we implemented into the first part of this tutorial and make some modifications. That also means that, even if you don't want to read the previous part, at least you'll have to get the code and implement the demo app if you'd like to follow up this tutorial. So, I keep going having in mind that you have read or implemented the previous app of our example.

Let's get started.