Call a function from another Class - Obj C

Posted by AndrewDK on Stack Overflow See other posts from Stack Overflow or by AndrewDK
Published on 2010-06-18T01:14:21Z Indexed on 2010/06/18 1:23 UTC
Read the original article Hit count: 267

I'm trying to figure out how I can call a function from another one of my classes. I'm using a RootViewController to setup one of my views as lets say AnotherViewController

So in my AnotherViewController im going to add in on the .h file

@class RootViewController

And in the .m file im going to import the View

#import "RootViewController.h"

I have a function called:

-(void)toggleView {
//do something }

And then in my AnotherViewController I have a button assigned out as:

    -(void)buttonAction {
//}

In the buttonAction I would like to be able to call the function toggleView in my RootViewController.

Can someone clarify on how I do this.

I've tried adding this is my buttonAction:

RootViewController * returnRootObject = [[RootViewController alloc] init];
    [returnRootObject toggleView];

But I dont think that's right.

Thanks in advanced.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c