Archive for February, 2010
I’ve been programming for quite some time now, but until now I never understood why some programmers prefer
CONSTANT == var over
var == CONSTANT
It’s to avoid a common C coding mistake of using = instead of ==. If you use the former form, and you inadvertently use = instead of ==, the compiler will catch your mistake because you’d be trying to assign a value to a constant.
I never really needed this convention because I have always been careful with my ==’s. One of the earliest C lessons I’ve learned. Still, it’s helpful to understand why some veterans prefer one form over the other.
Session 2 was conducted on the same venue as, and right after the PhRUG meetup.
There were two new attendees, tin and nico, who promised to catch up with the previous assignments.
We discussed memory management. The following questions were raised:
When should you call release on an object?
When you’re the one who did the alloc for the object.
When should you not call release?
When you did not do the alloc for the object.
Why bother with alloc and init at all, when, for example, you can use class methods that do it for you?
For example, why use:
NSString *my_string = [[NSString alloc] initWithFormat:@"format"];
when you can instead the format below?
NSString *my_string = [NSString stringWithFormat:@"format"];
Answer: The stringWithFormat call returns an autoreleased object. On the Mac OS X desktop, there’re practically no difference. On the iPhone, you want to limit the number of objects in the autorelease pool and use alloc/init most of the time so that you can be explicit (and optimize) on when you call release.
As before, let’s try to do Week 3 in one week. That means lectures 5 (Views, Animation, OpenGL) and 6 (View Controllers), and assignment 3 (HelloPoly II). Let’s aim to view the lectures and finish the assignment by next week and have a meetup Thursday next week, February 25.
For those that are catching up and still working on previous assignments, feel free to post questions about them, both on the forum and on meetups.
The folks at web-geeks.com have organized a free class for Cocos2d and iPhone SDK 3.1.2:
It starts on Feb.15. Even if you don’t know anything about Objective-C and Cocoa, you still have some time to cram. You can actually get by with what you’ll learn from the first three chapters of this book: Beginning iPhone Development: Exploring the iPhone SDK.
See you in the class!
Er, the class is virtual, so see you in the class forum instead.
We had our first session last night, February 4. Johann of Sagada Solutions was kind enough to host the meet-up.
We skipped discussion of assginment 1A as it was really very simple and no one had problems with it.
Assignment 1B has four sections, so we took turns in discussing our solutions. Paul discussed section 1, Topher section 2, Rad section 3 and Eumir section 4.
Topher mentioned some confusion in creating the project under XCode 3.2/Snow Leopard. The screenshot provided by the handout was for XCode 3.1/Leopard. If you’re on XCode 3.2/SL, see the screenshot below on how the New Project dialog should look like.
Everyone was excited and wanted to try a bit faster pace. Tentatively, the next meetup is on Thursday, February 11. It will cover Lectures 3-4 and assignments 2A and 2B. We’ll check our progress over the weekend, and if this pace doesn’t seem workable, people should cry chicken as early as Monday, February 8.
Lastly, the off-topic discussions were also productive. Here are the links to the tools mentioned in passing during last night’s meetup:
Topher’s framework of choice for building iPhone apps:
Rad’s framework of choice for building iPhone games:
Rad’s framework of choice for Flash games: