Archives for February 2013

Last updated by at .

iOS Programming Recipe 15: Building A Weather Application

This recipe will cover building a basic weather application for the iPhone from start to finish (no graphics needed, all code). Initially, this application will be very basic, but many enhancements/improvements may be the topic of future recipes. This recipe will move fast! If you find yourself having trouble keeping up you should go back and work through our earlier recipes before attempting this one. When you’re done with this recipe, you should have an app that looks like the following:


Before We Get Started

  • This application will be built using CocoaPods which is an Objective-C dependency manager. If you are not familiar with CocoaPods or just need some help getting it installed please visit their website. Additionally, there is a very good video tutorial on CocoaPods that NSScreencast has done which is currently free to view. Make sure you get CocoaPods installed on your system before starting this article, because installation will not be covered in the recipe.
  • The application will also use API provided by Weather Underground which will require you to sign up for a free developer API Key (limited to 500 requests per day I believe). Don’t worry this is very simple and will be covered in the recipe.
  • The source code to this recipe is available online through GitHub, and it may help to check it out when working through this tutorial.

[Read more…]

iOS Programming Recipe 14: Implementing A UICollectionViewController

UICollectionView is great for displaying information in a grid or other custom layouts. In iOS 6 you’ll see collection views most likely used in many apps such as the podcasts app for viewing different podcasts. Since in most cases you’ll want to use UICollectionViewController, we’ll focus on that for this recipe.


  • You are familiar with Xcode and setting up a single view controller. If not check out our recipe on Xcode first.

Setting Up The View

Go ahead and create a new single view controller project. I titled mine “CollectioViewFun”. When the project opens up, You’ll want to delete the single view controller from the storyboard and drag a new collection view controller in it’s place. This should look like the following:


Now since our class type has changed from a standard view controller to a collection view controller we’ll want to change the class type in the viewController.h file as well. Go ahead and change the class name from ViewController to CollectionViewController as well. Don’t forget to change all instances of the term “ViewController” in both the .m and .h files:

[Read more…]

iOS Programming Recipe 13: Using Property Lists (Plists)

In Recipe 11 we created a UITableview which relied on 4 arrays to supply the data sources with data. Since we didn’t have much data, this wasn’t an issue, but what if we wanted 40 different animals? Then our arrays would be very long. One way we can organize this data a little better is through the use of a Property Lists (Plist). Plist can be handy for storing Arrays, Dictionaries, and Strings.


  • You have looked over Part 1 and 2 of the UITableview recipes. I’ll be modifing the Tableview example a bit to remove these arrays and include them into a plist so you may want to go read those.

First, A Word on Property Lists

Plists are basically just text files intended to be more of a readable source of static values. In general, Don’t use them if:

  1. Your data is large. The entire Plist gets loaded into memory and is therefore large data doesn’t play well with them.
  2. You need relationships. Actions such as joins and searches don’t work at all in plist.
  3. You need to update often, edit data, remove items. These are all operations that are better suited for a Core Data or SQL.
  4. Your data does not consist primarily of strings and numbers.

So there you have it in a nutshell! Feel free to check out the documentation on the Mac Developer Library here

Creating The Property List

Alright, while there are a few formats of Plist (XML,binary,ASCII), XML is the most prevailent so we’ll be proceeding with this recipe using XML. Where we left off in the UITableview tutorial, the viewDidLoad method had four defined arrays. We’ll be removing these arrays and putting that data into a Plist instead. The viewDidLoad method looked like this when we left off:

[Read more…]

iOS Programming Recipe 12: Saving Time With Literals


  • You have basic knowledge of Objective-C and Foundation.
  • You are familiar with NSArray and NSDictionary.
What Are Literals?

Literals in programming refer to constant values that can be directly written out in source code.

"dog food"      //C string literal  
@"dog food"     //Obj-C string literal  
17              //integer literal    
17.0f           //float literal

The listing above shows a few common examples of literals you probably use frequently.

[Read more…]

iOS Programming Recipe 11: Using The UITableView Part II

In Part I of this recipe we left off with a UITableView that Displayed some creatures which were grouped by type. In this Recipe we’ll be extending the functionality a bit and emplement a delegate in order to handle a touch event. In addition, we’ll take a minute to explore styling of the table view and cells.


  • You Have already read through Part I, if not read through that first.

Styling The Table View

The next two sections will be brief, but I thought it was worth visiting since there are a few things that can be done right from the property inspector.

First of choose the tableview object from the storyboard and go to the property inspector tab on the top right hand pane. Choose Grouped from style section and go ahead and change default to some color, I change mine to blue.

[Read more…]

Privacy Policy