Re: XML Resource Release

2011-05-20 Thread Bing Li
Dear Gary, The Help of Xcode says the returned C string is automatically freed just as a returned object would be released. That means I don't need to release or autorelease xmlStr? Thanks, Bing On Sat, May 21, 2011 at 3:28 AM, Gary L. Wade wrote: > In your Xcode text window, hold down the opti

Re: XML Resource Release

2011-05-20 Thread Gary L. Wade
In your Xcode text window, hold down the option key and double click on NSString. You will be given the option of viewing an overview of the class. Click on the icon in the upper right side of the window that looks like a book. This will show you a view of the documentation for NSString. When l

Re: XML Resource Release

2011-05-20 Thread Bing Li
Dear Evadne and all, I appreciate so much for your replies! You change the return value from (const char *) to (NSString *). In my system, since I need to send the XML to a server via BSD socket. I have to convert it to (const char *). But I got another problem. If autoreleasing xmlStr or releas

Re: XML Resource Release

2011-05-20 Thread Bing Li
Dear Jeff and all, I appreciate so much for your help! After reading the document from apple.com, I changed my code as follows. It must be fine. Best regards, Bing + (const char *) CreateSignInMessage: (NSString *)peerKey PN: (NSString *)peerName PW:(NSString *)password { NSXMLElement *r

Re: XML Resource Release

2011-05-19 Thread Jeffrey Walton
On Wed, May 18, 2011 at 2:16 PM, Ken Thomases wrote: > On May 18, 2011, at 12:55 PM, Bing Li wrote: > >>        NSXMLElement *root = [NSXMLNode elementWithName:"MessageRoot"]; > > As per Cocoa's memory management conventions, you don't not own the object > returned by -[NSXMLNode elementWithName:

Re: XML Resource Release

2011-05-18 Thread Hank Heijink (Mailinglists)
On May 18, 2011, at 1:55 PM, Bing Li wrote: > Dear all, > > I am creating an XML chars to transmit over TCP. When an XML is created, I > attempt to release some resources. However, I got some weird results. > > The XML is simple as follows. > > > >2412432 >greatfree >1

Re: XML Resource Release

2011-05-18 Thread Fritz Anderson
On 18 May 2011, at 12:55 PM, Bing Li wrote: >NSXMLElement *root = [NSXMLNode elementWithName:"MessageRoot"]; >NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] > initWithRootElement:root]; >[xmlDoc setVersion:"1.0"]; >[xmlDoc setCharacterEncoding:"utf-8"]; // etc

Re: XML Resource Release

2011-05-18 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bing Li wrote: > But, if the releasing lines are changed as follows, it gets exceptions. > > > > [passwordElement release]; > [peerNameElement releases]; // The line is added. > [root release]; > [xmlDoc release];

Re: XML Resource Release

2011-05-18 Thread Ken Thomases
On May 18, 2011, at 12:55 PM, Bing Li wrote: >NSXMLElement *root = [NSXMLNode elementWithName:"MessageRoot"]; As per Cocoa's memory management conventions, you don't not own the object returned by -[NSXMLNode elementWithName:]. You have not invoked a method whose name contains "alloc",

XML Resource Release

2011-05-18 Thread Bing Li
Dear all, I am creating an XML chars to transmit over TCP. When an XML is created, I attempt to release some resources. However, I got some weird results. The XML is simple as follows. 2412432 greatfree 11 The code to create the above XML is as follows. It runs