Displaying an Objective C view into Cocos-2dx

I’m trying to display the music library from the users IOS device to play music, while an app is running. I’m currently doing this by using the main body of my code to call a .mm file, which then calls an Objective C file with the code that displays the IOS library, but it won’t show it because I don’t have direct access to the view I’m trying to add it to. Warning: Attempt to present <MPMediaPickerController: 0x7a0d3120> on <myClass: 0x7a0d2b40> whose view is not in the window hierarchy!

  -(void)addMusicBtnAction{
        MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeAnyAudio];
       mediaPicker.delegate = self;
       mediaPicker.prompt = NSLocalizedString (@"Select any song from the list", @"Prompt to user to choose some songs to play");
      for (UIWindow* window in [UIApplication sharedApplication].windows) {
          NSArray* subviews = window.subviews;
          if ([subviews count] > 0)
               for (UIAlertView *alrt in subviews) {
                  if ([alrt isKindOfClass:[UIAlertView class]]){
                     if (alrt.tag == 10020) {
                         [alrt dismissWithClickedButtonIndex:0 animated:YES];
                }
            }
        }
}
[self presentViewController:mediaPicker animated:YES completion:nil];
 }

Isn’t the top-level view retrieved via:

Director::getInstance()->getOpenGLView();

then it’s just a case of adding the Objective-C as a subview of this view? I am not sure, to be honest, having never actually done this myself…

My code doesn’t recognize Director

That’s probably because it’s in the cocos2d namespace.

Normally you’d put this at the top of the .cpp file in order to avoid writing the cosos2d bit:

USING_CC_NS;

Alternatively use cocos2d::Director::getInstance()->getOpenGLView().