我正在按名称动态调用方法。这是我正在使用的代码:
NSString *methodName=[NSString stringWithFormat:@"%@HintButton",stringForPredicate];
SEL s = NSSelectorFromString(methodName);
[self performSelector:s withObject:hItem];
我检查并且 s 值是
另一个声音提示按钮
我的代码中有以下方法:
- (void )AnotherSoundHintButton:(HintItem*) hItem {
[self PlaySound:hItem.hint];
}
但是当我运行我的应用程序时,出现以下错误:
2013-05-29 12:18:39.945 Game[19668:c07] -[SoundViewController AnotherSoundHintButton]: unrecognized selector sent to instance 0x8c60e90
2013-05-29 12:18:39.946 Game[19668:c07] Uncaught exception: -[SoundViewController AnotherSoundHintButton]: unrecognized selector sent to instance 0x8c60e90
2013-05-29 12:18:39.947 Game[19668:c07] Stack trace: (
0 CoreFoundation 0x01c4202e __exceptionPreprocess + 206
1 libobjc.A.dylib 0x019b5e7e objc_exception_throw + 44
2 CoreFoundation 0x01ccd4bd -[NSObject(NSObject) doesNotRecognizeSelector:] + 253
3 CoreFoundation 0x01c31bbc ___forwarding___ + 588
4 CoreFoundation 0x01c3194e _CF_forwarding_prep_0 + 14
5 libobjc.A.dylib 0x019c96b0 -[NSObject performSelector:withObject:] + 70
6 Game 0x00008ab9 -[SoundViewController alertView:clickedButtonAtIndex:] + 969
7 UIKit 0x00ced0bc -[UIAlertView(Private) _buttonClicked:] + 294
8 libobjc.A.dylib 0x019c9705 -[NSObject performSelector:withObject:withObject:] + 77
9 UIKit 0x008fd2c0 -[UIApplication sendAction:to:from:forEvent:] + 96
10 UIKit 0x008fd258 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
11 UIKit 0x009be021 -[UIControl sendAction:to:forEvent:] + 66
12 UIKit 0x009be57f -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
13 UIKit 0x009bd6e8 -[UIControl touchesEnded:withEvent:] + 546
14 UIKit 0x0092ccef -[UIWindow _sendTouchesForEvent:] + 846
15 UIKit 0x0092cf02 -[UIWindow sendEvent:] + 273
16 UIKit 0x0090ad4a -[UIApplication sendEvent:] + 436
17 UIKit 0x008fc698 _UIApplicationHandleEvent + 9874
18 GraphicsServices 0x02ab8df9 _PurpleEventCallback + 339
19 GraphicsServices 0x02ab8ad0 PurpleEventCallback + 46
20 CoreFoundation 0x01bb7bf5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
21 CoreFoundation 0x01bb7962 __CFRunLoopDoSource1 + 146
22 CoreFoundation 0x01be8bb6 __CFRunLoopRun + 2118
23 CoreFoundation 0x01be7f44 CFRunLoopRunSpecific + 276
24 CoreFoundation 0x01be7e1b CFRunLoopRunInMode + 123
25 GraphicsServices 0x02ab77e3 GSEventRunModal + 88
26 GraphicsServices 0x02ab7668 GSEventRun + 104
27 UIKit 0x008f9ffc UIApplicationMain + 1211
28 Game 0x00002724 main + 164
29 Game 0x00002635 start + 53
)