Calling methods

Discussion in 'iOS Programming' started by lynkynpark86, Feb 20, 2011.

  1. lynkynpark86 macrumors 6502

    I've got a nib with two views. The classes for these views are "OfflineMusicViewController.h" (and .m), and PlayingView.h (and .m). In the main view of the xib (OfflineMusicView), there's a button that is supposed to a) start playing a music file (w/ AVFoundation), and b) switch to a new view in the same xib (PlayingView) that has a button that stops the music and closes the second view, going back to the first. I've got the AVAudioPlayer (theAudio) in OfflineMusicViewController.h, but I need to use "[theAudio stop];" in PlayingView.m. How can I give theAudio a command from a different class file?
  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    You need a reference to the instance of the other class in the instance you want to call it from.
  3. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    You are mixing up your views and viewControllers. Normally, you should have a single viewController that is responsible for the (sub)views that, appropriately, it controls.

    Have you read through the View Controller Programming Guide for IOS yet? If not, you should. This should help you sort the difference between views and viewControllers.

Share This Page