iOS Tutorials / Objective-C Tutorials / Basic Course

Creating tables using custom UITableView & what is an NSArray

iOS Tutorials / Objective-C Tutorials / Basic Course IMG_0633.JPG

In the past two tutorials you have learned how to use basic UIKit controls like button, switches or sliders and have learned how to link all the stuff together.

Today we’ll try something a little bit more complex. Tables are a cornerstone of many iOS or tvOS apps. Probably not many games uses them but they are still very popular amongst iOS developers.

To master table views you will need to understand the concept of delegates as you will be needing them to pass all your data into the table.

I am not sure if you have heard about MVC on iOS yet but it would be great if you could google some high level information about the concept as we won’t have time cover this topic here. Me myself I don’t believe a proper MVC is possible on iOS or tvOS just because Apple is making us use ViewControllers. In our example we will have our views, model, view controller and a data controller so the result could be named something like an MVVC probably :)

Anyway, our view controller will manage all the views, will create a data controller and assigns it to your views. All data will come from a Model and will be passed into our data controller without ever touching the view controller.

I have again prepared an empty project for you. This time I have created a new project from a xxxxxxxxxxxxxxxxxxx view. Left the UI and Unit testing checked as well as Core Data which we’ll be using later in a part two of this tutorial. 

I am using github.com to host the files and throughout my tutorials you will be directed to incremental releases of the project. Our starting template is marked 1.0 and it only contains an empty iPhone app project with pre-generated view controller and some core data code which we’ll be using later.

When using delegates, whenever they have been provided to you by Apple like in case of our table view or you are creating your own delegate methods to allow communication between your custom classes, you need to declare that your class conforms to the delegate protocol. (I’ll try to make the sentences shorter I promise!). By telling Xcode that your class conforms to a protocol you are getting access to all the methods declared in the specific protocol.

Ondrej Rafaj

Ondrej is a developer, director in several startups and manages XPROGRESS just like that, just for fun!

More Posts - Website - Twitter

Categories: iOS Tutorials, Objective-C Tutorials, Basic Course

Post a new comment