J'ai des problèmes de fuite de mémoire avec cette fonction. Je pensais créer un NSArray avec componentsSeparatedByString était autorelease mais les instruments semblent indiquer une fuite au NSArray aPair. Pourquoi indiquerait-il une fuite ici et pas aussi dans les autres NSArrays créés de la même manière?NSArray with componentsSeparatedByString fuite de mémoire
-(void) checkRequest: (NSString *)request view:(UIViewController *)theView webView:(UIWebView *)wView
{
//NSLog(@"JSResponder - checkRequest()");
NSString *aRequest = [NSString stringWithString:request];
NSArray *urlArray = [aRequest componentsSeparatedByString:@"?"];
if([urlArray count] > 1)
{
NSString *paramsString = [urlArray lastObject];
NSString *cmd = @"";
NSArray *urlParamsArray = [paramsString componentsSeparatedByString:@"&"];
int numCommands = [urlParamsArray count];
NSMutableDictionary *paramsWithNames = [[NSMutableDictionary alloc ] initWithCapacity:numCommands];
for (NSString *elementPair in urlParamsArray)
{
NSArray *aPair = [elementPair componentsSeparatedByString:@"="];
NSString *aKey = [aPair objectAtIndex:0];
NSString *aParam = [aPair objectAtIndex:1];
if([aKey compare:@"_command"] == NSOrderedSame)
{
cmd = aParam;
}
else
{
[paramsWithNames setValue: aParam forKey:aKey];
}
}
[self executeCommand: cmd withParams: paramsWithNames view:theView webView:wView];
[paramsWithNames release];
}
}
Cette fonction nous appelle par ce qui suit:
- (void)pullJSEvent:(NSTimer*)theTimer
{
NSLog(@"MainView - pullJSEvent()");
NSString *jsCall = [NSString stringWithString:@"if(typeof checkOBJCEvents == 'function'){checkOBJCEvents();}"];
NSString *jsAnswer = [[webView stringByEvaluatingJavaScriptFromString:jsCall] retain];
if([jsAnswer compare:@"none"] != NSOrderedSame)
{
//NSLog(@" answer => %@", jsAnswer);
[jsResponder checkRequest:jsAnswer view:(UIViewController *)self webView:self.webView];
}
[jsAnswer release];
}
-vous Remerciez