Memory management question.
Memory management question.
- Subject: Memory management question.
- From: Scott Andrew <email@hidden>
- Date: Fri, 25 Mar 2005 00:43:48 -0800
I am just learning (making the jump form C++ and windows land) and I have a
question..
Everywhere I read it talks about having to release stuff that you alloc or
using autorelease to have it cleaned up automatically.
I have the following code..
-(bool)login:(NSString*)userName password:(NSString*)password
{
NSString* urlString = [[[NSString alloc]initWithFormat:@"%@%@",
baseURL, loginurl] autorelease];
NSMutableURLRequest* request = [NSMutableURLRequest
requestWithURL:[NSURL URLWithString:urlString]];
NSError* error;
NSURLResponse* response;
NSString* data = [[NSString alloc]initWithFormat:loginData, userName,
password];
// turn on the cookies from logon on..
[request setHTTPShouldHandleCookies:YES];
[request setHTTPMethod:@"POST"];
[request addValue:pbasePostHeader forHTTPHeaderField:@"Content-Type"];
NSData* body = [NSData dataWithData:[data
dataUsingEncoding:NSASCIIStringEncoding]];
[request setHTTPBody:body];
NSData* page = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error];
bool result = (page != nil);
if (result)
result = ![[response URL] isEqual: urlString];
[data release];
return result;
}
So I am relesaing my string I use to create the data for the body. Why don't
I have to release my request or body? When I do the app crashes.
According to MallocDebug and leaks nothing is leaking. So I am just curious
about this.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden