PDA

View Full Version : Memory allocation problem




Sergio10
Sep 22, 2009, 05:31 AM
Hi,

According to string I'd like to create new string but it crashes:

- (NSString*)test
{
switch (self.type)
{
case SHIPMENT_LIST_XML:
{
NSString *xml = [[NSString alloc] initWithString:[parser nodeValue:PARAM_1]];

if(xml == nil)
{
return nil;
}
else
{
[parser deleteNode:PARAM_1];

return xml;
}
} break;
}
return nil;
}

Do I create xml value correctly?

Thank you,
Serhiy Otroshchenko



dejo
Sep 22, 2009, 10:25 AM
I'd like to create new string but it crashes
Crashes how? Are there run-time errors? Specifics would be a big help.

Darkroom
Sep 22, 2009, 12:17 PM
i believe switch statements can only receive integers as arguments. try using if.

dejo
Sep 22, 2009, 12:23 PM
i believe switch statements can only receive integers as arguments.
No, they can be simple constants or constant expressions. The problem is the OP's code snippet is too vague to draw any conclusions about things like this and therefore very hard to diagnose why it doesn't work. That's why I asked for more specifics.

Darkroom
Sep 22, 2009, 12:29 PM
No, they can be simple constants or constant expressions.

good to know :)