Greg’s Online CS 193P Resources

May 1, 2009

Evan suggests solutions to Common Nil Object Problems

Filed under: cs 193p — gregorykaiser @ 2:58 pm
Tags:

At the 5:20 mark in lecture #9 Evan talks for 5 minutes about two problems in assignment #2 and #3 much discussed in this group …

1. Calling a method does nothing -> Your object is probably still = nil. A message to a nil object won’t fail and won’t do anything. He suggests using NSLog or the debugger to track this down.

2. IBOutlet variables are set up in IB but are nil in your code -> Evan reminds us that the Nib loading is “lazy” and not to use these variables in -init. Put code for these variables in -viewDidLoad (usually just called once after load of Nib) or -viewWillAppear (called before the view is displayed like during the pushing and popping of views with navigation bar). I had exactly this problem when I did the Presence 1 assignment. I put the view update code right after where they set the Title in the -init method and it did not seem to do anything.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: