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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:17:08+00:00 2026-06-11T11:17:08+00:00

If a function I called from inside a block references ‘self’, would that create

  • 0

If a function I called from inside a block references ‘self’, would that create a retain cycle?

__weak id weakSelf = self;

- (void)firstFunction
{
    id strongSelf = weakSelf;
    if (!strongSelf) return;

    [anObject performBlock:^{
        [strongSelf secondFunction];
    }];
}

- (void)secondFunction
{
    [self doSomeCrazyStuff];
    self.counter++;
    //etc.
}

I’m calling ‘self’ in ‘secondFunction’, do I need to pass my weak pointer into this function and use it instead?

  • 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-11T11:17:09+00:00Added an answer on June 11, 2026 at 11:17 am

    Potentially.

    A retain cycle is created by having a cycle of strong references, apart from the qualifier (i.e. weak, strong) on the variable the actual variables where those references come from is irrelevant. So strongSelf referenced by your block is a strong reference to self and you have the same potential for a retain cycle as if you’d used self itself.

    Re: comment

    Having your block maintain a weak reference is the standard approach to addressing this issue. If you use weakSelf in your block then there is no strong reference, if by the time the block is called weakSelf is nil then the call [weakSelf secondFunction] will do nothing – you are allowed to message nil in Objective-C. You won’t create a cycle, during the call of the block a strong copy of the reference may be created but this will go after the call to the block returns.

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

Sidebar

Related Questions

I have a shell function that is called from inside my map function. The
I have a Javascript function that is called from the onchange method in a
Does the entrySet() function that is called from a treemap instance return a TreeSet
I have a function that is being called from different threads in the application.
I detoured LoadLibraryA, in order to block the function from being called into my
I have a C function in MyClass and can call it from inside that
We've got a number of python libraries that need to be called from inside
I try to debug a javascript function called from Generate Thumbnails plugin in Wordpress.
I read in a Byte Array generated from a function called from an external
I'm trying to call a function called animateRight in a file called ScanAnimation.m from

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.