views:

111

answers:

1

Hi, I've an issue with this piece of code:

NSURL *url = [[NSURL alloc] initWithString:@"http://authenticate.radonsystems.net/products.xml"];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];

//Initialize the delegate.
XMLParser *parser = [[XMLParser alloc] initXMLParser];

//Set delegate
[xmlParser setDelegate:parser];

//Start parsing the XML file.
BOOL success = [xmlParser parse];

if(success)
    NSLog(@"No Errors");
else
    NSLog(@"Error Error Error!!!");
} // this is the breakpoint!

I've listed where the breakpoint is - (I've placed one on every line of code in the area)

Now at this point, success = NO, and looking back through the code, I reach the first line. XCode tells me that the url variable is out of scope with code 0x15db010.

What does this mean?

A: 

Due to code being optimised during compilation, your breakpoint isn't actually on the exact line you specify.

In this case, your breakpoint is set on a closing }. The compiled code won't have a } and so the breakpoint is set on something breakpoint-able after that line.

Since the breakpoint is somewhere after the } your NSURL instance is out of scope.

Try break pointing at the beginning if the method and stepping through each line.

Jasarien
thanks - for some reason, this chunk of code was after the window was made :/
Shamil