Search code examples
iphoneuiviewtouchesbegan

self.viewDelegate = 0x0 why?


In the following code the self.viewDelegate is 0x0 and I don't know how to solve this problem. Should I have to go to the interface Builder?

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [[event allTouches] anyObject]; 
    if ([touch tapCount] == 2) {
        if ([self.viewDelegate respondsToSelector:@selector(openFlowView:doubleTapOnIndex:itemView:)])
            [self.viewDelegate openFlowView:self doubleTapOnIndex:selectedCoverView.number itemView:selectedCoverView];
        }

Solution

  • viewDelegate is not defined.
    Usually, in Apple class, view delegate is just call delegate. You should have taken this code from somewhere. You have to defined viewDelegate in your code (not IB)

    self.viewDelegate=xxxx;
    

    xxxx must be your delegate. Delegate could be self !

    See Apple doc for delegate explanation