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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:34:26+00:00 2026-05-26T07:34:26+00:00

Before the ARC was in place for ios development, i have been using something

  • 0

Before the ARC was in place for ios development, i have been using something like this in viewDidLoad to setup my navigation items:

self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneClicked:)] autorelease];

How can i implement this correctly while ARC is enabled for my view controller while keeping it a 1 line deal?

I know about prepending the __autoreleasing, __strong, etc, but i don’t see how i can create this rightBarButtonItem without separating it into 2 lines like this:

__autoreleasing UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneClicked:)];
self.navigationItem.rightBarButtonItem = rightBarItem;
  • 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-26T07:34:27+00:00Added an answer on May 26, 2026 at 7:34 am

    You don’t need to use __autoreleasing qualifier in this situation. The rightBarButtonItem has a strong reference for the assigned object, and then the assigned object will be automatically released when the rightBarButtonItem is released (when UINavigationBar is released).

    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneClicked:)];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before you answer this I have never developed anything popular enough to attain high
I have the following code and am getting this error before compiling: Fast Enumeration
Using Xcode 4.2 and ARC, I wrote the following code before I had any
I have a project that contains some files that are using ARC, and some
I am using this class: https://github.com/alexleutgoeb/ALPickerView Since I converted to ARC, I get this
Before I start, I know there is this post and it doesn't answer my
Before I do this I figured I would ask if it was the best
Before, I have found the Cost in the execution plan to be a good
Before anyone suggests scrapping the table tags altogether, I'm just modifying this part of
Before you start firing at me, I'm NOT looking to do this, but someone

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.