views:

142

answers:

3

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

A: 

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

Lakshmie
I copied this up into your question to keep it together.
itsmatt
Thanks Matt... I am relatively new to this place... :)
Lakshmie
A: 

I created a view controller for the view and allowed communication between the view controllers. Perhaps this is part of the MVC protocol.

Lakshmie
If this is part of your question, edit the question instead of putting this in an answer.
progrmr
A: 

Check the value of viewController at the point where it is used to make sure its not nil, use the debugger or add NSLog:

[viewController pointToSummary:[touch locationInView:self].y];
NSLog(@"viewController=%@", viewController);
NSLog(@"Helloooooo"); 
progrmr