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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:31:42+00:00 2026-06-14T21:31:42+00:00

I have an ivar like this declared on interface: BOOL controllerOK; I have to

  • 0

I have an ivar like this declared on interface:

BOOL controllerOK;

I have to use this ivar inside a block that resides itself in a block. Something like

myBlockl = ^(){
  [self presentViewController:controller
    animated:YES
    completion:^(){
      if (controllerOK)
        [self doStuff];
      }];
};

If I try to do that, I see a warning:

capturing self strongly in this block is likely to lead to a retain cycle

for the if (controllerOK) line.

This does not appear to be one of those blocks problems that you create another variable using __unsafe_unretained before the block starts. First because this instruction cannot be used with a BOOL and second because the ivar controllerOK has to be tested on runtime inside the block. Another problem is that the block itself is declared on the interface, so it will be used outside the context where it is being created.

How do I solve that?

  • 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-14T21:31:43+00:00Added an answer on June 14, 2026 at 9:31 pm

    This should work:

    __weak id this = self;
    myBlockl = ^(){
      [self presentViewController:controller
        animated:YES
        completion:^(){
          if (this->controllerOK)
            [this doStuff];
          }];
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my iOS5 app for iPhone I have something like this AppDelegate ivar ViewController1
I have noticed that most Objective-C coders never use the self->ivar syntax when accessing
Previously I have always seen example of use of properties and iVars like this...
I have always wondered why all apple code samples use code like this: UINavigationController
EDIT: I seem to have found something that's helped. I retained the ivar stack
Say I have a class like this: @interface MyAwesomeClass : NSObject { @private NSString
A quick question. if I have a property and an ivar declared with the
I have a NSOperation that downloads some data using NSURLConnection, it looks somewhat like
Suppose I have two buttons that are ivar outlets. One is called Blue and
I would like to implement a shuffle function, I have this piece of code

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.