Module 1 – Lesson 10

This is our last class.

Firstly, an early greetings for the Chinese New Year. Wish you all a great year of the dragon and good luck to your iOS app endeavor.

There is no slides for this lesson. We focus mainly on finishing up last lesson’s exercise. We will also try to do a supplementary exercise related to UITabbarController.

Downloads

Module 1 – Lesson 9

Class exercise night! Everyone will get their hands dirty and mind inspired doing 3 hours of Objective-C coding! Awesome!

Downloads

Module 1 – Lesson 8

On engineering side, we went through, finally, an important piece of iOS technology – memory management.

This is an important piece of knowledge for building apps and save you time from debugging weird crashing bugs. iOS 5 comes with a new technology called Automatic Reference Counting. This new technology replaces the memory management convention “retain/release” we discussed in class. However, this new technology still requires you to have knowledge in object graph, object ownership and memory management.

Video

Out soon…

Download

References

Assignment 2

Assignment 2 is a simple one. It should not spend more than 2 hours of your time.

This assignment helps you understand memory management in Obj-C. This is an essential piece of knowledge if you wanna continue your endeavor in iOS development. So, spend a weekend evening with it.

All instructions are in the assignment sheet. Download and read the whole thing. Deadline: 10 Jan 11:59 pm.

Make sure you follow the deadline and submission instruction!!

Assignment 1 feedback

Assignment 1 marked.

I honestly feel proud to the 20 of you who have handed in the assignment. You guys have leveled up! All (except for 1) submitted can be compiled and run without me having to fix anything for you. This is a great achievement for beginners! You guys rock!

Some facts of the assignment:

  • 20 submissions
  • Average score: 10.05 (out of 20)
  • Highest: 14
  • Lowest: 4 (late submission)

There are several common problems though:

  • Objective-C
    • Use Obj-C naming convention
    • Memory management – retain/release, autorelease
    • Read Coding Guidelines
    • Read Xcode warning!
  • Image Assets
    • Size – check documentation
    • Resolution – 72 DPI
    • No color profile
    • Use “stretchable image”
  • Miscellaneous
    • Read assignment sheet
    • Don’t send me stuff I do NOT ask for. No PSD nor AI file.

Update – 13 Jan

Checkpoint 5 of assignment for your reference

Module 1 – Lesson 7

This is the first lesson in 2012! Wish you a wonderful and exciting year in iOS development!

Learning programming is like learning a musical instrument. It’s easy to pick the basic skills, play a jingle. But it’s very difficult to play well. You need broad and deep understanding to iOS (and, generally, software engineering).

There’s no secret nor is there shortcut. You just need to work very hard and think through problems. There are loads of Angry Birds clone in the App Store. But the most popular bird game is still Angry Birds. You can argue that there are some really good clone. But, no matter how fine the gap between good and great is, good is not great.

Having said that, we actually did it quite well. As I comment in class, all submitted assignments (except for 1) are compilable and runnable. This is a big deal for beginner!. The assignment gave us a good chance to experience iOS development too.

Lesson 7 is for table view and navigation controller. Check the slides together with video recordings for the basic.

When you are done, check the Stanford video in the References section below.

Recordings

Downloads

Reference

5 Jan – guest speaker night

Great news! Jeffery creator and designer of HK Weather app will be with us on 5 Jan.

Jeffery runs his own company – Conceptable which focuses on mobile application development. You can check their recent works here.

I will have a short interview with him in class which will be followed by demo of his products. We will end the session with Q&A.

Module 1 – Lesson 6

One hour of engineering lecture and 2 hours of design workshop

Summary

On engineering side, we discussed about UIViewController. This is the centerpiece of the MVC (Model-view-controller) design pattern.

This can be a little vague for people who have no programming experience. In the lecture, I explained, using the Angry analogy, how this MVC pattern applies to the app. Check the video recording if you don’t fully understand what is MVC.

Apart from conceptual idea of UIViewController, we discussed how UIViewController takes part in application launch. Please refer to the slides for detail.

iOS provides several built-in view controllers to support common interface paradigms:

References

Downloads

Video Recording

Assignment 1 Tips

As many of us are not familiar with software development, here’s some extra tips to help you out on some key parts of this assignment

Float-point number

Floating-point number should be used instead of integer. We should perform all calculation using “double” data type to simplify our work for this assignment.

Storing  input value

All of us have used calculator before. We probably haven’t paid much attention to its behavior though.

Let’s study the case where you are entering the value “123″ to a calculator.

The sequence of keys you will type is as follow:

  • “1″ key
  • “2″ key
  • “3″ key

This key pattern needs to be translated into a numeric value that is stored in your iPhone as “123″

Let’s study the integer value. We define a variable of type “double” in the view controller class.

double inputValue;

When user taps “1″ key, the value stored in “inputValue” is 1.

When user taps “2″ key, we should…

inputValue = inputValue * 10.0 +;

Since inputValue is current “1″ and user is pressing key “2″, the above equation will becomes:

inputValue = 1.0 * 10.0 + 2.0

inputValue will be storing 12.

When user taps “3″ key, the same should formula should be used.

Now, let’s consider the case user enters “0.987″.

This time the situation is different.

When user tap “0″ key, inputValue = 0.0

When user taps “9″ key, we should use this formula instead:

inputValue = 9.0 / 10.0 + inputValue

When user taps “8″ key,

inputValue = 8.0 / 100.0 + inputValue

We need to keep track of which decimal place user is entering. Therefore, we need to introduce an extra variable to store that.

double decimalValue = 0.0;

when user has tap “.” key, set…

decmialValue = 10.0;

From here, whenever the user taps a numeric key, multiply decimalValue by 10.

decmialValue *= 10.0;

As you can see, the logic to handle the integer part and the decimal part are quite different. I would suggest to use 2 variables to store values instead of storing both parts of the value in the same “inputValue” variable.

Put the following in your view controller header file.:

double integerStore, decmialStore;

Identify what key is pressed

How can we identify what key the user has tapped?

I’ll suggest either one of the following case:

- Set the “tag” property in UIButton from interface builder. Or,

- Do a string comparison

If you use the first method, you will get a bonus. Please refer to the assignment sheet.

The 2nd method is more straight forward. The label in the button shows the vale already. However, that value is a string. We need to identify the string and make that a numeric value.

You can use titleForState: to get the string value. Then, perform a string comparison as follow:

- (IBAction)keyPressed:(id)sender {
    // cast the sender into a button

    UIButton * btn = sender;

    if (  [[btn titleForState:UIControlStateNormal] isEqualToString:@"1"] ) {
        // do something
    } else if ( [[btn titleForState:UIControlStateNormal] isEqualToString:@"2"] ) {
        // do something
    } // continue the "if" condition for all keys
    NSLog(@"Key code pressed: %d", btn.tag);
}

String formatting

User input and calculation result are output to a UILabel. Read documentation of UILabel. UILabel accepts only string value.

We need to convert the result to a string.

Use “stringWithFormat” to convert double into a string. Read String Format Specifiers in String Programming Guide documentation for that.

yourLabel.text = [NSString stringWithFormat:@"%d", integerStore + decimalStore]

Button Background

To customize button look-and–feel, follow the steps here.

You need the button background image, download stuff from class web site.

You need to prepare 2 sets of graphics – one for Retina display (hi-res) and one for standard resolution. Make sure you import the 2 versions of graphics to Xcode. The graphic assets I prepared contain both set of images.

If you need an image button_bg.png, the hi-res version of it MUST be named button_bg@2x.png

If you wanna know know, read here for details about preparing graphics for retina display check the following:

Module 1 – Lesson 5 – Object-oriented programming

Sorry, I was late for class and planned too much for the workshop session. I will reduce the amount of things to cover in worksheet next time.

Lesson 5 is the class of workshop.

On the engineering side, we work on the Lesson 5 Class Exercise. It contains procedures where we have a hands-on in object-oriented programming.

The exercise is base of a fictions case where we wanna create a bird to show on the screen. We want you to have hands-on experience with the following important concept:

One thing is left in the class exercise. The middle part on P.4 where you are asked to “Create your own bird”. We will get back to that in the next class.

The class exercise was too long this time. I thought we accomplish more since, last lesson, we went through most theory.

Sorry for those of you who have finished up the design class exercise. Yannic will follow-up on that next class.

Additional Reading

Textbook – Programming iOS 4

  • Chapter 4
  • Chapter 5

Downloads

Video Recording

Follow

Get every new post delivered to your Inbox.