0
votes

I am using xcode and interface builder 3.2.5, and am trying to implement the first app from the http://appsamuck.com/day1.html website. I believe that I have followed all of the instructions, but the app fails to work. The app teaches how to create a label called countdownLabel (on top of a black background) within the view and connects the countdownLabel through the Interface Builder. The app starts a timer within the appDelegate:

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    timer = [NSTimer scheduledTimerWithTimeInterval:(1.0) target:self selector:@selector(onTimer) userInfo:nil repeats:YES];

... }

On each timer tick, the appDelegate onTimer method calls a viewController method to update the countdownLabel with a string that identifies the hours, minutes and seconds before midnight. When the app runs, the countdownLabel never updates. Instead, the background turns white.

When I set breakpoints, I see that the timer is running properly (i.e. a periodic call to onTimer occurs) and calling the method to update the countdownLabel. However, before the first timer event ever occurs, a call to the ViewController method "loadView" is made:

  • (void)loadView { [countdownLabel setFont:[UIFont fontWithName:@"DBLCDTempBlack" size:128.0]]; countdownLabel.text = @"I0A0IN6"; }

When I stop in this method, I see that the content of the countdownLabel is 0x0. If I continue the execution to a breakpoint within the appDelegate onTimer method, the screen turns white. This method then calls a method to update the countdownLabel, but the label never changes (probably because the value of the countdownLabel remains a value of 0x0).

Why is the countdownLabel 0x0? Is there some initialization or connection that I am missing?

1

1 Answers

1
votes

Double-check that you did these steps correctly (linking the IBOutlet in File's Owner to the label in Interface Builder)

Now we need to wire up the Label in Interface Builder to the UILabel in the class file

Reopen Interface Builder

Select the Label in the View or in Document Window

Click: Tools -> Connection Inspector

Move your mouse cursor over the empty circle to the right of text "New Referencing Outlet" (the circle will change to a Plus(+))

Mouse Click then drag the Plus (+) to "File's Owner" in Document Window

When you release select countdownLabel in the popup list

Click: File -> Save then close Interface Builder