"Figure 2.6 Console Output" issues - nothing in editor area


#1

Hey folks. Long time programmer, but as a command-line compiler type of guy, I’m still acclimating to the XCode IDE.
Hit a bit of a snag when I get to Figure 2.6 - the ‘Debug RandomPossessions’ entry is there in the log navigator, but the editor area is completely blank:


I’ve double-checked all my code & the build is reporting successful. There’s just no output to the debug console so I can confirm. Any suggestions? Am I missing an option somewhere (versions below)? I’ve not touched the xcode preferences.

[code]#import <Foundation/Foundation.h>

int main(int argc, const char * argv[])
{

@autoreleasepool {
    
    // Create a mutable array object, store its address in items variable
    NSMutableArray *items =[[NSMutableArray alloc] init];
    
    // Send the message addObject: to the NSMutableArray pointed to
    // by the variable items, passing a string each time.
    [items addObject:@"One"];
    [items addObject:@"Two"];
    [items addObject:@"Three"];
    
    // Send another message, insertObject:atIndex:, to that same array object
    [items insertObject:@"Zero" atIndex:0];
    
    // Destroy the array pointed to by items
    items = nil;
    
    // For every item in the array as determined by sending count to items
    for (int i = 0; i < [items count]; i++) {
        // We get the ith object from the array and pass it as an argument to
        // NSLog, which implicitly send the description message to that object
        NSLog(@"%@", [items objectAtIndex:i]);
    }
}
return 0;

}[/code]

OS X Lion 10.7 with latest updates
Xcode Version 4.3.2, default install options


#2

Oops, found my error! For those who didn’t spot the issue, I put my for loop after setting the item pointer to nil instead of before it :confused:

Here’s where the problem was:

[code] // Destroy the array pointed to by items
items = nil;

    // For every item in the array as determined by sending count to items
    for (int i = 0; i < [items count]; i++) {
        // We get the ith object from the array and pass it as an argument to
        // NSLog, which implicitly send the description message to that object
        NSLog(@"%@", [items objectAtIndex:i]);
    }

[/code]

Here’s what it should have looked like:

        // For every item in the array as determined by sending count to items
        for (int i = 0; i < [items count]; i++) {
            // We get the ith object from the array and pass it as an argument to
            // NSLog, which implicitly send the description message to that object
            NSLog(@"%@", [items objectAtIndex:i]);
        }

        // Destroy the array pointed to by items
        items = nil;

/facepalm