-(void)invokeMethod
{
NSMethodSignature * sig = [[source class] instanceMethodSignatureForSelector:@selector(mySelector:)];
NSInvocation * invocation = [NSInvocation invocationWithMethodSignature:sig];
[invocation setTarget:myTarget];
[invocation setSelector:@selector(mySelector:)];
MySubClassOfNSInvocationOperation * command = [[[MySubClassOfNSInvocationOperation alloc] initWithInvocation:invocation] autorelease];
//setArgument retains command
[invocation setArgument:&command atIndex:2];
//addOperation retains command until the selector is finished executing
[operationQueue addOperation:command];
}
-(void)mySelector:(MySubClassOfNSInvocation*)command
{
//Do stuff
}
Я не знаю точно, что происходит, но NSInvocation
& MySubClassOfNSInvocationOperation
проскальзываютКак я могу решить эту утечку памяти? NSInvocation
Когда я удалить строку:
[invocation setArgument:&command atIndex:2];
Это не утечка, так что какие-то проблемы с передачей команды в качестве аргумента.
Отлично. благодаря –