Calling a method in a view controller from a view

Posted by Lakshmie on Stack Overflow See other posts from Stack Overflow or by Lakshmie
Published on 2010-03-31T17:09:47Z Indexed on 2010/03/31 17:53 UTC
Read the original article Hit count: 375

I have to invoke a method present in a view controller who's reference is available in the view. When I try to call the method like any other method, for some reason, iPhone just ignores the call. Can somebody explain as to why this happens and also how can I go about invoking this method?


In the view I have this method:

-(void) touchesBegan :(NSSet *) touches withEvent:(UIEvent *)event{
NSArray* mySubViews = [self subviews];
for (UITouch *touch in touches) {
    int i = 0;
    for(; i<[mySubViews count]; i++){
        if(CGRectContainsPoint([[mySubViews objectAtIndex:i] frame], [touch locationInView:self])){
            break;
        }
    }
    if(i<[mySubViews count]){
                    // viewController is the reference to the View Controller. 
        [viewController pointToSummary:[touch locationInView:self].y];
        NSLog(@"Helloooooo");
        break;
    }
}

}

Whenever the touches event is triggered, Hellooooo gets printed in the console but the method before that is simply ignored

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c