Je reçois la fuite dans cette méthode même le nsstring alloué est libéré.Fuites dans le passage de la demande en utilisant l'URL à NSString, Objective-C
Maintenant, je suis pris stringWithFormat, mais encore, elle manifeste la fuite à "NSData * returnData = ...." ligne
-(BOOL)getTicket:(NSString*)userName passWord:(NSString*)aPassword isLogin:(BOOL)isLogin
{
NSString* [email protected]"";
if (isLogin == YES)
{
str =[NSString stringWithFormat:@"AGENT=true&LOGIN_ID=%@&PASSWORD=%@",[self _encodeString:userName],[self _encodeString:aPassword]];
}
else if (isLogin == NO)
{
str =[NSString stringWithFormat:@"AGENT=true&LOGIN_ID=%@&PASSWORD=%@",[self _encodeString:userName],[self _encodeString:aPassword]];
}
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:str]
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:25.0];
[request setHTTPMethod: @"POST"];
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
printf("\n returnString in getticket:%s",[returnString UTF8String]);
NSRange textRange;
textRange =[returnString rangeOfString:@"TICKET"];
if(textRange.location != NSNotFound)
{
NSArray* splitValues = [returnString componentsSeparatedByString:@"TICKET="];
NSString* str1 = [splitValues objectAtIndex:1];
NSArray* splitValues1 = [str1 componentsSeparatedByString:@"RESULT"];
NSString* ticket1 = [splitValues1 objectAtIndex:0];
self.ticket = ticket1;
self.isCorrectLogin = YES;
[returnString release];
return YES;
}
else
{
self.isCorrectLogin = NO;
[returnString release];
return NO;
}
return NO;
}
S'il vous plaît aidez-moi de ce problème.
Pouvez-vous suggérer comment ajouter en utilisant stringWithFormat pour un –
Je ne suis pas sûr de ce que vous demandez. – bbum