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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:26:01+00:00 2026-06-01T15:26:01+00:00

Say I have a class ObjectA (a view controller for example), that does this

  • 0

Say I have a class ObjectA (a view controller for example), that does this :

ObjectB *objectB = [[ObjectB alloc] init];

[objectB executeLongRequestThenDo:^ (NSDictionary *results)
 {
     self.datasource = results;
     [self.tableView reloadData];
 }];

ObjectA can be deallocated at any moment, so I should be able to cancel the request of objectB, and tell it not to execute the block when its done, right ? Simply releasing it is not enough ? Also, should I call release just after executeLongRequestThenDo: ?

  • 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-01T15:26:03+00:00Added an answer on June 1, 2026 at 3:26 pm

    No, ObjectA will not be deallocated at any moment — it will be retained until ObjectB is done with the operation.

    Probably -[ObjectB executeLongRequestThenDo:] will call Block_copy on the block. This will cause the block to be moved from the stack to the heap, and will retain all the NSObjects that the block directly references, namely self.

    When ObjectB is done, it should run the block, then call Block_release, which will release self. Or, if you have some way of canceling the operation, ObjectB should similarly release the block.

    (It’s possible that ObjectB will do this all indirectly, by calling something that does the work, like dispatch_async.)

    Reference: Blocks Programming Topics.

    As for when you should release objectB: it depends on whether it retains itself during the long-running operation, or not. To be safe, I would not release it until you know it’s fully complete, which would be at the end of your block, or after you’ve called its cancellation method.

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

Sidebar

Related Questions

This is a best practices question Let say, I have a class object, like
Say I have a tableview class that lists 100 Foo objects. It has: @property
lets say I have an NSWindow Class, that has several events for mouse and
Say I have the controller as follows: public class Controller { ISomeService _service; public
Let's say I have on my controller: @parts = Part.all and on the view
Let's say you have this Model: //model public class Stuff { public string Name
Let's say I have a generic Object class, and a generic List class. I
Let's say we have a collection of Person objects class Person { public string
Let's say I have an object: public class CustomObj { DateTime Date { get;
Let's say I have created two objects from class foo and now want to

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.