Note that there are some explanatory texts on larger screens.

plurals
  1. POSending a message to an object
    primarykey
    data
    text
    <p>I'm pretty new to Objective C but things are progressing well. However, I think I'm missing a key concept relating to how objects are created and messaged. I hope someone can help me.</p> <p>I'm creating an iPhone app that simply creates a MPMusicPlayer, and starts playing a song from the que.</p> <p>I create the music player (myPlayer) in the AppDelegate like so...</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. // Add the main view controller's view to the window and display. [window addSubview:mainViewController.view]; [window makeKeyAndVisible]; // instantiate a music player MPMusicPlayerController *myPlayer = [MPMusicPlayerController applicationMusicPlayer]; // assign a playback queue containing all media items on the device [myPlayer setQueueWithQuery: [MPMediaQuery songsQuery]]; // start playing from the beginning of the queue [myPlayer play]; return YES; </code></pre> <p>}</p> <p>This works fine. Now in the MainViewController I try to send myPlayer the command to skip to the next track </p> <pre><code>[myPlayer skipToNextItem]; </code></pre> <p>However when I try to compile I get the message that myPlayer in undeclared.</p> <p>What am I doing wrong? I can see how I could fix this in a procedural way (by creating the player in the MainViewController), but I'd like to understand what I have to do to get it working in and OOP way.</p> <p>Cheers,</p> <p>Richard</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload