Calling a method across implementation files

Discussion in 'iOS Programming' started by mcannell, Dec 21, 2008.

  1. mcannell macrumors member

    Dec 20, 2008
    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];

  2. mcannell thread starter macrumors member

    Dec 20, 2008
    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)
  3. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    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.

Share This Page