can i Pass gesture recogniser in a notification

Total Post:28

 1057  View(s)
Rate this:

I am sending a notification from one class to another to call a method using

[[NSNotificationCenter defaultCenter] postNotification:

[NSNotification notificationWithName:@"gestureIsOn" object: self ]];

WhatI want to achieve here is to receive the notification in another class but also passing the UIGestureRecognizer to find which view it is, as the class receiving the notification contains 4 different views. I already tried to implement the receiving of the notification like this:

[[NSNotificationCenter defaultCenter] addObserver:self

                                             selector:@selector(handleGestures::) name:@"gestureIsOn"

                                             object:nil ];

and call the method handleGestures:

-(void)handleGestures:(UIGestureRecognizer *)sender :(NSNotification *)notification { 

if(sender.view == view1)

do something


Tried to use double :: in my observer notification but this causing an error of Terminating app due to uncaught exception 'NSInvalidArgumentException'

Thanks in advance to everyone that spend time reading this.

  1. Post:214

    Re: can i Pass gesture recogniser in a notification

    You could send it like this:

    [[NSNotificationCenter defaultCenter] postNotificationName:@"gestureIsOn"



    And on the receiving side:

    UIGestureRecognizer *recognizer = notification.userInfo[@"recognizer"];


      Modified On Apr-10-2018 01:30:58 AM