【发布时间】:2013-10-16 03:52:29
【问题描述】:
我在我的应用程序中使用 ARC 并因此出现新的崩溃:
malloc: *** error for object 0x17e9a5d0: double free
*** set a breakpoint in malloc_error_break to debug
为了弄清楚,我启用了 Zombie Objects ,原因是:
*** -[CFString release]: message sent to deallocated instance 0x15d183e0
我的代码:
Class myClass = NSClassFromString(classString);
SEL mySelector = NSSelectorFromString(selectorString);
NSString *arg = @"arg";
NSMethodSignature *sig = [myClass methodSignatureForSelector:mySelector];
NSInvocation * myInvocation = [NSInvocation invocationWithMethodSignature:sig];
[myInvocation setTarget: myClass];
[myInvocation setSelector: mySelector];
[myInvocation setArgument:&arg atIndex:2];
NSString *result = nil;
[myInvocation retainArguments];
[myInvocation invoke];
[myInvocation getReturnValue: &result];
NSLog(@" Result String : %@ ",result);
出了什么问题?哪个 CFString ?? 感谢您的任何回复。
编辑:
对象NSString *result 导致。下一步如何纠正这个错误?
【问题讨论】:
-
在创建每个对象时打印它的地址,您就会(从错误消息中)知道是哪一个导致了问题。
标签: ios objective-c automatic-ref-counting