View Full Version : Calling a method across implementation files

Dec 21, 2008, 09:01 PM
I am new to Objective-C, Cocoa, & iPhone SDK.

This seems to me like it should be very easy to do but I have spent hours trying to find the solution.

I have a RootViewController with a method in it that I want to call from MainView.m. Why isn't this a very simple thing to do? I've searched, read through Objective-C books, begged, nothing works...


-(void) myMethod {
// do something amazingly great

#import "MainView.h"
#import "RootViewController.h"

-(IBAction) myOutlet{
// do some calculations here
// set some variables here

//Now call method inside RootViewController
[RootViewController toggleView];


Dec 21, 2008, 09:27 PM
BTW, It builds but when the button is clicked I get:


0x95490fb0 <+0000> push %ebp
0x95490fb1 <+0001> mov %esp,%ebp
0x95490fb3 <+0003> int3
0x95490fb4 <+0004> leave <---------------------------------- red arrow here
0x95490fb5 <+0005> ret
0x95490fb6 <+0006> nopw %cs:0x0(%eax,%eax,1)

Dec 21, 2008, 10:45 PM
Well, I won't give you the outright answer but I will give you somewhat of a hint. You have myMethod declared as an instance method but you are trying to access it using the class method approach.