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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:38:49+00:00 2026-05-26T18:38:49+00:00

The old way that I was doing this in iOS 4 was by declaring

  • 0

The “old” way that I was doing this in iOS 4 was by declaring the object in the header file and passing the object for a write-back to handle an error parameter.

NSError *error;

For reasons beyond my limited knowledge I could not continue this pattern in iOS5 and received the error:

“Passing address of non-local object to _autoreleasing parameter for write-back”

//Instantiate an instance of AVAudioSession object
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
//Setup playback and Record
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&error ];

The temporary solution for me is to do this:

NSError *theError = nil;

//Instanciste an instance of AVAudioSession object
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
//Setup playback and Record
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&theError];
//Activate session
[audioSession setActive:YES error:&theError];

This is annoying as I have to create this local object each time I need to use it in Xcode.

My question is: Is there a better way of doing this in the new ARC paradigm?

I found a similar question here in stack overflow that deals with this issue sort of…
here

  • 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-26T18:38:49+00:00Added an answer on May 26, 2026 at 6:38 pm

    The preferred way to handle this situation in the event you actually wanted to use the ivar NSError *error would be:

    NSError *theError = nil;
        //...
    [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&theError];
    if (theError != nil){
        error = theError;
        //Handle failure
    }
    [audioSession setActive:YES error:&theError];
    if (theError != nil){
        error = theError;
        //Handle failure
    }
    

    My guess is that you mean to ignore the errors entirely, forgive me if I’m wrong. That can be done by simply doing this (though not recommended):

    [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
    [audioSession setActive:YES error:nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it better to use a stored procedure or doing it the old way
I'm used to the old Winforms way of doing things. Apparently WPF ListViews are
What is the most efficient way to write the old-school: StringBuilder sb = new
Is there an easy way to compare the file tree of an old git
We've got a reasonable sized C++ application that's pretty old at this stage, so
I'm remaking an old warcraft 3 custom game that I used to play way
I have a file that has over 200 lines in this format: name old_id
I'm still learning Perl, so there's probably a more efficient way of doing this.
Is there a way in mercurial to remove old changesets from a database? I
Ideally I'd like a way to enable the mouse wheel for scrolling in old

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.