Debugging classes returns nil


I’ve jumped a chapter or two here and there, so I understand it’s probably my own fault.

I’ve been following the Chapter 28 code, and copied it letter for letter, however debugging:

Returns nil.

One thing that I noticed was that in ScheduleClass.h the @property for begin is set to nonatomic, strong yet when I tried that, I get errors about assigning etc. So for now, I set it to assign rather than strong or copy.

ScheduleFetcher.m looks like this:

// ScheduleFetcher.m
// RanchForecast
// Created by James Brooks on 07/12/2011.
// Copyright 2011 Blue Bay Travel. All rights reserved.

#import “ScheduleFetcher.h”
#import “ScheduledClass.h”

@implementation ScheduleFetcher

  • (id)init
    self = [super init];
    if (self) {
    classes = [[NSMutableArray alloc] init];
    dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@“yyyy-MM-dd HH:mm:ss zzzz”];

    return self;

  • (NSArray *)fetchClassesWithError:(NSError **)outError {
    BOOL success;
    NSURL *xmlURL = [NSURL URLWithString:@“”];

    NSURLRequest *req = [NSURLRequest requestWithURL:xmlURL

    NSURLResponse *resp = nil;

    NSData *data = [NSURLConnection sendSynchronousRequest:req returningResponse:&resp error];

    return nil;

    [classes removeAllObjects];

    NSXMLParser *parser;
    parser = [[NSXMLParser alloc] initWithData:data];
    [parser setDelegate:self];

    success = [parser parse];
    if(!success) {
    *outError = [parser parserError];
    return nil;

    NSArray *output = [classes copy];

    return output;

#pragma mark -
#pragma mark NSXMLParserDelegate Methods

  • (void)parser:(NSXMLParser *)parser
    didStartElement:(NSString *)elementName
    namespaceURI:(NSString *)namespaceURI
    qualifiedName:(NSString *)qName
    attributes:(NSDictionary *)attributeDict {
    if([elementName isEqual:@“class”]) {
    currentFields = [[NSMutableDictionary alloc] init];
    }else if([elementName isEqual:@“offering”]) {
    [currentFields setObject:[attributeDict objectForKey:@“href”] forKey:@“href”];

  • (void)parser:(NSXMLParser *)parser
    didStartElement:(NSString *)elementName
    namespaceURI:(NSString *)namespaceURI
    qualifiedName:(NSString *)qName {
    if([elementName isEqual:@“class”]) {
    ScheduledClass *currentClass = [[ScheduledClass alloc] init];
    [currentClass setName:[currentFields objectForKey:@“offering”]];
    [currentClass setLocation:[currentFields objectForKey:@“location”]];
    [currentClass setHref:[currentFields objectForKey:@“href”]];

      NSString *beginString = [currentFields objectForKey:@"begin"];
      NSDate *beginDate = [dateFormatter dateFromString:beginString];
      [currentClass setBegin:beginDate];
      [classes addObject:currentFields];
      currentClass = nil;
      currentFields = nil;

    }else if(currentFields && currentString) {
    NSString *trimmed;
    trimmed = [currentString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
    [currentFields setObject:trimmed forKey:elementName];

    currentString = nil;

-(void)parser:(NSXMLParser *)parser
foundCharacters:(NSString *)string {
if(!currentString) {
currentString = [[NSMutableString alloc] init];

[currentString appendString: string];


I’ve connected my tableView dataSources etc, but alas, no data.

Any ideas?

P.S awesome book! I’m going to Jamaica on Saturday so I’ll be reading through it all over again.


So the strong keyword problem was related to me needing to upgrade Xcode from 4.1.2 to 4.2.1 :slight_smile:

But still, no data in my table view.


If classes is nil, that would suggest that -init isn’t being called. Can you put a breakpoint in -init and determine if that’s the case?


Hmm, didn’t seem to breakpoint.

I don’t even get a log output anymore. I definitely did before I started with the interface. Back I go.


How about in -applicationDidFinishLaunching:? Is the ScheduleFetcher being created there and so forth?