When I construct a dynamic URL using NSString stringWithFormat and then use that value in my XML parser I get random crashes. However if I test it with a constant string it works fine…
This is my code for generating the string,
loginURL = [NSString stringWithFormat:@"%@%@",ScriptURLString,@"authenticate"];
Which results in,
http://edms.digistorm.com.au/test/index.php?s=&sc=D41D8CD98F00B204E9800998ECF8427E&m=authenticate
Then I use it in my XML parser,
XMLReturnData = [[NSMutableArray alloc] init];
xml = [[XMLParser alloc]
initWithXMLPath:loginURL
lookForElement:@"Authenticate"
setCallbackObject:self
withSelector:@selector(dataReady)
data:XMLReturnData
];
For some reason this is causing my app to crash. If I use a constant string like,
loginURL = @"http://edms.digistorm.com.au/test/index.php?s=&sc=D41D8CD98F00B204E9800998ECF8427E&m=authenticate";
it works fine…
loginURL is defined as NSString *loginURL; inside my header file for this view.
Any help or guidance would be much appreciated!
Thanks,
Tim
This shows your string is get released and when you calls it in XML parser it crashes the app.
actually
stringWithFormat gives aautoreleaseobject for string.So what you need,make your string as retain property inside .h then synthesize it in .m and release it in dealloc method.
and also do this,
in
viewDidLoadNow when you use
stringWithFormatuse like thisIt solves your problem.