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 5976579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:14:57+00:00 2026-05-22T21:14:57+00:00

Should I release NSBundle in the below code or not? NSURL should also be

  • 0

Should I release NSBundle in the below code or not? NSURL should also be release or not?
I am confused.

NSBundle  *mainBundle = [NSBundle mainBundle];
NSError   *error;
NSURL     *audioURL = [NSURL fileURLWithPath:[mainBundle pathForResource:@"count_in" ofType: @"mp3"]];
AVAudioPlayer *player1 = [(AVAudioPlayer*) [AVAudioPlayer alloc] initWithContentsOfURL:audioURL error:&error];
self.player =   player1;
[self.player play];
[player1 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-05-22T21:14:57+00:00Added an answer on May 22, 2026 at 9:14 pm

    You should not release NSBundle and NSURL instances because you haven’t alloced these.

    From the apple Documentation.

    You take ownership of an object if you create it using a method whose
    name begins with “alloc”, “new”,
    “copy”, or “mutableCopy” (for example,
    alloc, newObject, or mutableCopy), or
    if you send it a retain message.

    You use release or autorelease to relinquish ownership of an object.
    autorelease just means “send a release
    message in the future” (specifically:
    when the used autorelease pool
    receives a drain message—to understand
    when this will be, see “Autorelease
    Pools”).

    I would highly recommend you to clear your memory management concept.

    Read the apple article on
    Memory Management Rules

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

Sidebar

Related Questions

UIButton *btn = [[UIButton alloc]init]; In the above code, I should release btn because
I have a LAMP (Linux/Apache/MySQL/Php) application that I should release soon. Even if I've
My base class has properties that are used by a subclass. where should Release
Should I always release self when there is a failure inside init, or should
We should have a full release of asp.net MVC well before .NET 4.0 and
What should I do if I want to release a .net assembly but wish
Should I turn on Generate Debug Symbols in Xcode for release configuration? When it
When should I include PDB files for a production release? Should I use the
What are release notes for and who reads them? Should/could they be automated by
Note: Typically in a dealloc method you should release object instance variables directly (rather

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.