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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:06:57+00:00 2026-06-08T02:06:57+00:00

This is regarding use of __block for releasing an object inside block; NSString *str

  • 0

This is regarding use of __block for releasing an object inside block;

NSString *str = [SomeObject methodName]; // returned object is autoreleased
[str retain];   //retaining the object since its auto released 

Now i will be using this str object inside a block. inside block i will be releasing this object.
Do i need to prefix with like __block NSString *str = .., since iam releasing it inside block?
From the rules i understand that if we want to modify an object inside block we need to prefix with __block. But does this rule applies for releasing also?

  • 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-08T02:07:00+00:00Added an answer on June 8, 2026 at 2:07 am

    No. __block is required for variables you want to modify. Releasing an object doesn’t mean modifying a variable. Rather, it means sending a release message to the object in question. Just as with any other message, there’s no reason you can’t send release to an object instance inside a block, even without the __block qualifier.

    You should be aware that for non-__block qualified object variables, the block will retain the object. So, while your explicit release inside the block may balance a retain outside/before the block is invoked, the object won’t actually be released (at least) until the block itself is released, even if no other object has retained it.

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

Sidebar

Related Questions

I have an issue regarding Sendkeys Class, as i want to use this class
After reading this: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-to-use-it I came to the conclusion that it is not valid
After reading this article http://lukast.mediablog.sk/log/?p=155 I decided to use mingw on linux to compile
Reading about Django, I saw this: http://docs.djangoproject.com/en/1.1/ref/contrib/admin/#ref-contrib-admin - the fancy simple to use admin
is it better to do this (regarding performance, not readability...): $('a.updateCartButton').click(function() { $('form[name=updateCartForm]').attr('action', $(this).attr('href')
This is regarding a project that concerns detection of text in an image using
This is regarding the jsTree jQuery plugin . I've been struggling with this for
This is regarding AES algorithm. Suppose i have implemented a AES algorithm and encrypt
H Regarding this URL http://www.codeproject.com/KB/aspnet/FlashUpload.aspx User.Identity as System.Web.Security.FormsIdentity is always null, because the Identity
In this documentation regarding statistical facet in ElasticSearch , at the bottom of the

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.