Announcing Our First AppCoda Book – Learn iOS 7 Programming from Scratch

I got something big to share with you. Our very first AppCoda book – Learn iOS 7 Programming from Scratch is now live and ready for purchases!

If you’re a follower of our blog, you know we encourage the “Get Your Hands Dirty” way (or what-so-called “Learning by Doing” approach) to study programming. Learning a new programming language is quite similar to learning a foreign language. You can’t just read a book and teach yourself Spanish (or any other languages). You have to practice, practice and practice! That’s the same for studying a new programming language.

This 400-page book is written with that in mind and based on our popular programming course. The book starts with the basics and walk you through the process to create iOS apps using iOS 7 SDK and Xcode 5. After you learn how to build a simple iPhone app, you’ll learn how to master table view and build a simple recipe app. Each chapter you’ll learn something more advanced than the one before.

Learn iOS 7 Programming from Scratch

Programming should be fun to learn. I tend not to bore you with programming concepts. Instead, you’ll get lots of hands-on exercises and create loads of apps in this 30-chapter book. You’ll need to code, debug and build some real apps. There are a lot of works to do but it would be a fantastic experience and you’ll master the fundamentals of iOS 7 programming along the way.

[Read more...]

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?

Well, a block is a self-contained, autonomous code fragment, existing always into the scope of another programming structure, as for example the body of a method. The code on the block can “interact” with the world out of it, but what takes place in the block is not visible to the scope out of it. Also, blocks can modify the values of variables being out of its body using a special way (we’ll see more later). Blocks have two great features:

  1. They can be executed in a later time, and not when the code of the scope they have been implemented is being executed.
  2. Their usage leads eventually to a much cleaner and tidier code writing, as they can be used instead of delegate methods, written just in one place and not spread to many files.

Introduction to Blocks

Focusing even more on the second feature, blocks offer a nice solution for creating callbacks instead of delegates, as they are declared and implemented directly to the point of the code where they are invoked. Using blocks, there is no need to adopt protocols, or implementing delegate methods that lead to much more code in a class. The best thing though, is that the callback procedure can directly access and use any variables existing locally in the scope where the block has been defined, so the need of passing data like we do in callback methods is eliminated. However, blocks cannot totally replace delegates as they cannot be used for every purpose. The best practice is to make combination of both, and that can be achieved both by following some simple rules and using the experience obtained in time.
[Read more...]

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.

Before we proceed to take a tour on the most important aspects of the address book framework through a demo application, it would be a nice idea to make an introductory discussion first that will make easier to everyone to comprehend what comes next in this tutorial. So, keep reading and surely you’ll find some pretty interesting stuff as food for thinking and study.

addressbook-featured
[Read more...]

How to Use UIPageViewController to Build Tutorial Screens

Editor’s note: For the very first time you launch an app, you’ll probably find a series of tutorial screens to walk you through the basic features. It’s a common practice to explain how the app works. This week, we’ll show you how to build a similar type of tutorials by using UIPageViewController.

The UIPageViewController class was introduced into the iOS 5 SDK as a mechanism to implement a page turning style of user interface in iOS applications. The UIPageViewController is a highly configurable class that it lets developers to configure:

  • the orientation of the page views – vertical or horizontal
  • the transition style – page turning style or a dot based style
  • the axis (spine) on which the page will turn

In this tutorial we are going to show how to use the UIPageViewController to implement an app that allows users to scroll between multiple screens. You can find examples of this type of page view implementation in games like Angry Birds to show the available levels or in apps that include tutorial/walkthrough screens.

Sample Walkthrough Screens from Path

Sample Walkthrough Screens from Path

Prior to iOS 5 we had to use the UIPageControl class and explicitly control the animations, as well as, transitions between pages. This procedure has been highly simplified with the introduction of the UIPageViewController. We’ll keep the demo app very simple and focus to demonstrate the usage of UIPageViewController. However, with the basic understanding of the page view controller, you can easily build the tutorial screens in your app.
[Read more...]

Back To Basics: Intro to Object Oriented Programming

If you’re our long time follower, you know we’ve gone pretty far. By now, you should be able to build an iPhone app with tab bar, navigation controller and table view using Storyboard. One request on the top of my list, however, is to enhance the detail view of the Recipe app. Many readers mentioned the original detail view is too plain. How can we display more information including an image? That shouldn’t be difficult if you understand the materials and I intentionally left out that part for you at the time I wrote the tutorial. :-)

Did you manage to create your own detail view for the Recipe app? Anyway, we’ll revisit it and show you how to improve the detail screen. But before that, I have to introduce you the basics of Object Oriented Programming. In the next tutorial, we’ll build on top of what we learn in this tutorial and enhance the detail view screen.

Don’t be scared by the term “Object Oriented Programming” or OOP in short. It’s not a new kind of programming language but a programming concept/technique. I intentionally left out the OOP concept when I first began writing the iOS programming tutorials. I want to keep thing simple and show you (even without any programming background) how to create an app. I don’t want to scare you away with technical term. However, I think it’s time to cover the concept. If you’re still around reading this article, I believe you’re determined to learn iOS programming and you want to take your app to the next level.
[Read more...]

Storyboards Segue Tutorial: Pass Data Between View Controllers

This is the second article of our Storyboards series. In the first tutorial, we introduced the Storyboards, which is a friendly feature in Xcode for designing user interface. If you’ve followed the tutorial from start to end, you should already build a simple recipe app with navigation interface. But we left one thing that was not discussed: data passing between scenes (i.e. view controllers) with segue.

First, let’s take a quick look at what we’ve accomplished. Previously, we learnt to use Storyboards to build a few things:

  • Embedded a normal view controller in navigation controller
  • Created a table view and populate a list of recipes
  • Switched from one view controller to another view controller using Segue

And, this is the final deliverable. When the app is launched, it displays a list of recipes. Tap on any of them will bring you to another view, that supposes to display the details of recipes.
[Read more...]

iOS Programming Basic: How Does the Hello World App Work?

I hope you enjoy the first iOS programming tutorial and already created your first app. Before we move onto the next tutorial and build a more complex app, let’s step back and have a closer look at the Hello World app. It’ll be good for you to understand some of the Objective-C syntax and the inner workings of the app.

So far you follow the step-by-step guide to build the Hello World app. But as you go through the tutorial, you may come across these questions:

  • What are those .xib, .h and .m file?
  • What are those “ugly” code inside “showMessage”? What do they mean?!
  • What actually happens after you taps the “Hello World” button? How does the button trigger the “showMessage” action?
  • How does the “Run” button in Xcode work?

I want you to focus on exploring the Xcode environment so I didn’t explain any of the above in the previous post. Yet it’s essential for every developer to understand the inner details behind the code and grasp the basic concept of iOS programming. For some technical concepts, they may be a bit hard to understand particularly you have no programming background. Don’t worry, however. This is just a start. As you move on and write more code in later tutorials, you’ll get better understanding about iOS programming. Just try your best to learn as much as possible.
[Read more...]

Hello World! Build Your First iPhone App

Update: This tutorial only works for Xcode 4.6 or lower. If you’ve upgraded to Xcode 5, please check out the updated Hello World tutorial.

I hope you have configured your development environment properly with Xcode installed. If you haven’t done so, check out our previous article about what you need to begin iOS programming. We’ll use Xcode 4.3.2 to work on the tutorial. However, you can also Xcode 4.2 to build the app in case you can’t upgrade to the latest version of Xcode.

You may have heard of “Hello World” program if you have read any programming book before. It has become the traditional program for first-time learner to create. It’s a very simple program that usually outputs “Hello, World” on the display of a device. In this tutorial, let’s follow the programming tradition and create a “Hello World” app using Xcode. Despite its simplicity, the “Hello World” program serves a few purposes:

  • It gives you a better idea about the syntax and structure of Objective C, the programming language of iOS.
  • It also gives you a basic introduction of the Xcode environment. You’ll learn how to create a Xcode project and create user interface with the built-in interface builder.
  • You’ll learn how to compile a program, build the app and test it using the Simulator.
  • Lastly, it makes you think programming is not difficult. I don’t want to scare you away. :-)

[Read more...]