Question

I'm calling methods dynamically by name. this is the code I'm using:

NSString *methodName=[NSString stringWithFormat:@"%@HintButton",stringForPredicate];
            SEL s = NSSelectorFromString(methodName);
            [self performSelector:s withObject:hItem];

I Checked and s value is

AnotherSoundHintButton

I have the following method in my code:

- (void )AnotherSoundHintButton:(HintItem*) hItem {
        [self PlaySound:hItem.hint];
}

but when I run my app I'm getting the following error:

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
)
Was it helpful?

Solution 2

add column(:) after AnotherSoundHintButton

AnotherSoundHintButton:

OTHER TIPS

Try this :

 NSString *methodName=[NSString stringWithFormat:@"%@HintButton:",stringForPredicate];

The colon after "HintButton" is important.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top