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

  • SEARCH
  • Home
  • 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 8274809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:51:59+00:00 2026-06-08T07:51:59+00:00

Which of the following scenarios is correct coding practice, given that player is (nonatomic,

  • 0

Which of the following scenarios is correct coding practice, given that player is (nonatomic, retain), and is synthesized using player = _player.

Scenario A

MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
        self.player = mp;
        [mp release];

Scenario B

MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
    self.player = mp;

Up until this point I have been using scenario A as a general practice, but I think this may be causing memory leaks within my code.

Thanks for any help.

EDIT 1:

And does the same apply to Timers, they are causing me real hassle. If I’m using the code below is this correct? If timerMap is also (nonatomic, retain), and uses timerMap = _timerMap;

self.timerMap = [[NSTimer scheduledTimerWithTimeInterval:fps target:self selector:@selector(updateAnimationTimer) userInfo:nil repeats:YES] autorelease];

And when releasing is it fine to just invalidate, or should it be invalidate then release?

  • 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-08T07:52:01+00:00Added an answer on June 8, 2026 at 7:52 am

    Scenario A is definitely the way to go, Scenario B will leak mp

    Source : Apple Doc

    EDIT 1 :

    The code you posted is wrong, it will result in a crash when setting the timerMap property again. You must not autorelease it

    self.timerMap = [NSTimer scheduledTimerWithTimeInterval:fps target:self selector:@selector(updateAnimationTimer) userInfo:nil repeats:YES];
    

    When you don’t need the timer anymore, just

    self.timerMap = nil; 
    

    This will call the release method on the timer and will set the pointer to nil

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We upgrated Nhibernate to 3.2 and getting problem in following scenarios: Public properties which
Let's consider the following scenario: a function which can generate code colors from white
I have the following scenario. I have a search page which is split into
I am using the following which works great. I am just wondering if it
is following scenario possible? SessionService which is a stateless EJB fires an event LoggedInEvent.
I am using MySQL and I am having the following scenario: Table nodes: node_id,
The scenario is the following: I have a java package ( myapp.config ) that
I use JEditable for making edit field which following code: $(function() { $(.field).editable(http://localhost/index.php/welcome/update_record, {
I use the following which works perfectly in all browsers, except ie9 $result =
I found the following which shows how to delete an attribute from XML in

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.