Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8291859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T13:16:37+00:00 2026-06-08T13:16:37+00:00

I have an non ARC project. So i am maintaining its memory management. It

  • 0

I have an non ARC project. So i am maintaining its memory management. It has an tabbar and navigation controller.In that on launch before showing tab bar i have to show an launch video of 5 sec kind of thing. so i have two question

Best and easy way to show an view controller before attaching tab bar controller to main window without leaks.Following is my current technique and code but code analyzer is showing me potential leaks in my video controller.

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

UIViewController *viewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil] ;
myNavigationController = [ [ UINavigationController alloc ] initWithRootViewController: viewController ];
[viewController release]; 

NSMutableArray *viewControllers;
viewControllers = [[NSMutableArray alloc] init];
[viewControllers addObject: myNavigationController];  //Tab 1
myNavigationController release];
// ADD Tab 2    //ADD Tab 3    //ADD Tab 4
self.tabBarController = [[[UITabBarController alloc] init] autorelease];
self.tabBarController.viewControllers = viewControllers;
[viewControllers release];
//Add video contoller before showing tabs
self.videoController = [[VideoPlayViewController alloc] initWithNibName:@"VideoPlayViewController" bundle:nil];
[self.window addSubview:videoController.view];
[self.window makeKeyAndVisible];

Here is my Video Player controller code

- (void)viewDidLoad
{
   [super viewDidLoad];
   MPMoviePlayerController *moviePlayer =  [[MPMoviePlayerController alloc] initWithContentURL:@"some url"];
    //------ init code in between and added observer to movie playback finish callback ------
   [self.view addSubview:moviePlayer.view ]; //show potential leak here if i not release moviePlayer
    //[moviePlayer release]; //if i release here controller show me black window with no video playing
}

- (void) moviePlayBackDidFinish:(NSNotification*)notification {

    MPMoviePlayerController *player = [notification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerDidExitFullscreenNotification 
                                                  object:nil];
    [player stop];
    [player.view removeFromSuperview];
    [player release]; //show incorrect decrement of reference count of an object that is not owned at this point by caller
    //Fire notification to add tab bar as root view controller
}

And after video is played i get notificaton in my appdelegate and then

 [videoController.view removeFromSuperview];
 [self.videoController release];
 self.videoController = nil;
 self.window.rootViewController = self.tabBarController;

and my main app delegate dealloc as usual

- (void)dealloc {
    [_window release];
    [_tabBarController release];
    [super dealloc];
}

i think i explained my problem correctly.Please anyone have any better way to do this.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T13:16:38+00:00Added an answer on June 8, 2026 at 1:16 pm

    Declare the moviePlayer variable outside of viewDidLoad and then release it in moviePlayBackDidFinish. You’re adding a reference to it and then removing only that reference. The reason you’re being notified about a leak is that moviePlayer is never released – and with the current setup of your code you can’t release it.

    MPMoviePlayerController *moviePlayer; //keep reference to moviePlayer
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        moviePlayer =  [[MPMoviePlayerController alloc] initWithContentURL:@"some url"];
        [self.view addSubview:moviePlayer.view ];
    }
    
    - (void) moviePlayBackDidFinish:(NSNotification*)notification {
    
        [[NSNotificationCenter defaultCenter] removeObserver:self
                                                        name:MPMoviePlayerDidExitFullscreenNotification 
                                                      object:nil];
        [moviePlayer stop];
        [moviePlayer.view removeFromSuperview];
        [moviePlayer release];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an (non-virtualized) ItemsControl that binds its ItemsSource to a ObeservableCollection of ViewModel
Overview I have a iOS project in which the view controller implementation which has
Under ARC , I have an object, Child that has a weak property, parent
I have an OSX Cocoa ARC project that handles thousands of images. In order
I have a non ode function that calculates based on the previous time step
We have a non-profit web site that got about 5 million hits in May.
I have a non-Activity class (let's call it NonActivity) that needs to post a
The problem is the following. There are multiple rows that have non-unique identifiers: id
I have a code that has been working for almost 4 years (since boost
I would like to detect strings that have non-whitespace characters in them. Right now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.