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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:47:41+00:00 2026-06-09T00:47:41+00:00

I am having a hard time understanding this: __block __weak MyCell *weakSelf = self;

  • 0

I am having a hard time understanding this:

__block __weak MyCell *weakSelf = self;
[NetworkManager profileImageForUser:id success ^(UIImage *image, NSString *userId){
       weakSelf.leftImageView.image = image;
}];

The issue is that when MyCell is deallocated and then the success block is initiated, then it crashes saying unrecognized selector sent to instance. How do I deal with this?

  • 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-09T00:47:43+00:00Added an answer on June 9, 2026 at 12:47 am

    The reason this crash is happening is that weakSelf is not being retained by the block, which is probably executed asynchronously after the deallocation of the object.

    Why are you using __block here? This is the cause of your problem.

    __block is only necessary when you are going to MODIFY the object in question from inside the block. __block also prevents the behaviour of the block retaining the object. Since you are not changing the VALUE of weakSelf (only it’s properties), you should not use __block so that the block will retain the object and thus have it in memory when it is required, preventing this crash.

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

Sidebar

Related Questions

I'm having a hard time understanding this regex stuff... I have a string like
In general, the PHPDOC properties are self-explanatory, but I'm having hard time understanding these:
I'm having a hard time understanding how to implement a single model self-join in
I'm having a hard time understanding this piece of code. #define TABLE \ STATE(STATE_1,
I'm having a hard time understanding why this.$map and this.markers are undefined. Here's the
I am having a hard time understanding the following issue: This code does what
I'm having a hard time understanding this. Consider the following example: protected void Page_Load(object
i'm having a hard time understanding custom events and I keep getting this same
I'm doing some homework, and having a hard time understanding closures. This is in
I am having a hard time understanding this and hopefully someone can correct me

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.