0

I have a tap gesture recognizer that is supposed to call a method when a user taps on a particular area of the screen.

-(void)handleTapGesture:(UITapGestureRecognizer*)sender
{
    if (self.interfaceIsiPad) {
        [self.mController.view removeGestureRecognizer:sender];
        CGPoint point = [sender locationInView:self.mController.view];
        if (point.x<70 && point.y <50 ) {
            [self dismissModalViewCtrlAndNotifyDelegateOf:willExitOk withError:nil];// crash here
            return;
        }
    }
    else {
        [self.vc.view removeGestureRecognizer:sender];
    }

}

The dissmissModalVieCtrl method that crashes is a few lines of code beneath this method ... in the same class. However this always crashes with unrecognized selector sent to object

Why? I got NSString, UIAppearenceProxy and other class names with this crash... Why does self convert to some random class.

user1028028
  • 6,323
  • 9
  • 34
  • 59
  • Does the method `dismissModalViewCtrlAndNotifyDelegateOf: withError:` exist? – gitaarik Jan 20 '14 at 12:19
  • Can you post all stack error and dismissModalViewCtrlAndNotifyDelegateOf method? – Greg Jan 20 '14 at 12:20
  • 1
    Please add exception breakpoint and then point the line of code where occur crash. http://stackoverflow.com/questions/4961770/run-stop-on-objective-c-exception-in-xcode-4 This will give me more information – Robert Jan 20 '14 at 12:23
  • You need to post the full crash log, not just a summary. – occulus Jan 20 '14 at 13:07
  • 1
    Also, make sure your compiler warnings are turned on and set to the maximum level (`-Wextra` helps with that). – Richard J. Ross III Jan 20 '14 at 13:15
  • Yes, the method exists (it says so in the question) I set a exception break point... that is the line that it crashes on. – user1028028 Jan 20 '14 at 14:56

3 Answers3

0

Is your method really called dissmissModalVieCtrl (without a 'w')? If so, there's the reason for your unrecognised selected. Fix the spelling of your selector name, ensure it matches the method you're calling (which appears to actually be dismissModalViewCtrlAndNotifyDelegateOf:withError:).

Please post the code for this method that you're attempting to call.

If you do NSLog(@" self = %@", self);, what does self actually show up as?

occulus
  • 16,959
  • 6
  • 53
  • 76
0

My experience with continuously changing class types of self (or other objects) is, when the reference to that object is lost. So to say your self isn't valid when the method is called.

0

If you are using dismissModalViewCtrlAndNotifyDelegateOf to dismiss your current viewController,like using: dismissViewControllerAnimated: completion: it automatically forwards the message to the presenting view controller.

So you may have to check whether your presentingViewController is exist or not.

or you can override

- (void)forwardInvocation:(NSInvocation *)anInvocation;

to see whether your forwarding message is correct.

johnMa
  • 3,291
  • 24
  • 37