我在我的應用程序中使用ARC,並得到一個新的崩潰與這個原因:雙免費在ARC
malloc: *** error for object 0x17e9a5d0: double free
*** set a breakpoint in malloc_error_break to debug
弄明白,我啓用了殭屍的對象,其原因:
*** -[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
。如何在下一步更正這個錯誤?
打印每個對象的地址並創建它,並且您將知道(從錯誤消息)哪一個導致問題。 – Floris
謝謝@弗洛里斯。 – Carina