[IOS] Get the value by judging the type by the sender

1. Background: Because the program uses Notification, pass the value to a button event. The incoming parameter of the button event is (id) sender, so you need to convert the sender to get the incoming value of notification.

 

2. Code:

-(void)onCustomLeftButtonClick:(id)sender {
 if ([sender isKindOfClass:[NSNotification class]]) {
        
        NSString *showType = [sender object];
        
        if ([@"show_left" isEqualToString:showType]) {
            _slider_btn_flag = 101;
            return;
        }else if ([@"show_center" isEqualToString:showType]){
            _slider_btn_flag = 100;
            return;
        }
        
  }
 。。。。。

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326096111&siteId=291194637