Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
I'm having a problem. A portion of a subclass's init code does not appear to be being called. The rest of the init method is called.
Here is the code, straight from the relevant .m file:
Code:
-(id)init
{
    self = [super init];
    if (self != nil) {
        NSURL *xmlURL = [[NSBundle mainBundle] URLForResource:@"exerciseInfo" withExtension:@"xml"];
        // Do some stuff that is related to the XML parser.
        xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
        [xmlParser setDelegate:self];
        [xmlParser parse];
        xmlElements = [[NSMutableArray alloc] init];  // There is a breakpoint here, but it never pauses when it is supposed to.  It's not set to be ignored at all, and "Automatically continue after evaluating" is not checked.
        unendedElements = [[NSMutableArray alloc] init];
    }
    return self;
}

Edit: The object in question is being initialized.
 
Last edited:

plinden

macrumors 601
Apr 8, 2004
4,029
142
What happens when you set a breakpoint earlier, e.g. at the [super init], and step through the code?
 

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
What happens when you set a breakpoint earlier, e.g. at the [super init], and step through the code?

Every line of code that I posted gets executed except the last two lines of code that are in the if block.
 

mfram

Contributor
Jan 23, 2010
1,307
343
San Diego, CA USA
I'm guessing that by calling "parse" the delegate functions in your class will be called. If those delegate functions are trying to use xmlElements and uneededElements they can't because they haven't been allocated yet.

Maybe try moving the parse call after allocating those arrays.
 

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
I'm guessing that by calling "parse" the delegate functions in your class will be called. If those delegate functions are trying to use xmlElements and uneededElements they can't because they haven't been allocated yet.

There was a breakpoint just before the } in the init method I posted, but that did not get called.

Anyway, I am not looking for answers anymore.
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
I chose not to mark the thread "Resolved" because I moved the last two lines of code to a different method instead of attempting to make the code be executed in the init method.

I suggested marking the thread Resolved since you said you were no longer looking for answers to your query and thus others would not be tempted to provide further assistance. It's just a courtesy to those you seek help from.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.