0
我在用ARC測試NSInvocation,但它觸發內存泄漏。在MRC中,它運作良好。我不知道爲什麼。NSInvocation觸發內存泄漏
- (NSArray *)a:(NSString *)a b:(NSString *)b c:(NSString *)c
{
return @[a, b, c];
}
- (void)testNSInvocation
{
NSMethodSignature *sig = [self methodSignatureForSelector:@selector(a:b:c:)];
NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig];
[inv setTarget:self];
[inv setSelector:@selector(a:b:c:)];
NSString *a = @"a", *b = @"b", *c = @"c";
[inv setArgument:&a atIndex:2];
[inv setArgument:&b atIndex:3];
[inv setArgument:&c atIndex:4];
[inv retainArguments];
[inv invoke];
NSArray *ret;
[inv getReturnValue:&ret];//this is problem,but why?
NSLog(@"ret:%@", ret);
}