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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:53:42+00:00 2026-05-25T09:53:42+00:00

I did a small loader that I can stick on the UI when I

  • 0

I did a small “loader” that I can stick on the UI when I need it. Much like the UISpinnerView.

It has some logic (I simplified the code in the block for this post) that require it to be recursively called. I do it like this:

- (void) blink {

    tick++;

    if (tick > kNumberOfLights)
        tick = 0;

    UIView *lightOne = [self viewWithTag:kLightStartIndex];
    UIView *lightTwo = [self viewWithTag:kLightStartIndex+1];   

    [UIView animateWithDuration:0.5
                          delay: 0.0
                        options: UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseOut
                     animations:^{

                         if (tick == 0) {

                             [lightOne setAlpha:kLightOn];
                             [lightTwo setAlpha:kLightOff];                            

                         } else if (tick == 1) {

                             [lightOne setAlpha:kLightOff];
                             [lightTwo setAlpha:kLightOn];    
                         }
                     }
                     completion:^(BOOL finished){
                             [self blink];    
                     }];

}

The method [self blink] is called when the view is added to a super view.

There are no objects retained in the Loader class, so when I remove it in the super view
it is released. The problem is that if the animation block is running when I release the view, the completion block will call a deallocated object and cause the error:

(20380,0xa0a29540) malloc: * mmap(size=2097152) failed (error
code=12)
*
error: can’t allocate region

In the console and the error:

__[LoaderClass blink]_block_invoke_2

in the Debug Navigator.

How do I make sure to correctly tear down the view when it is removed from the super view?

  • 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-05-25T09:53:43+00:00Added an answer on May 25, 2026 at 9:53 am

    Overriding release is usually a bad idea, but this case might be an exception to the rule.

    Instance variables:

    BOOL isBlinking;
    BOOL releaseWhenDoneAnimating;
    

    Initialize isBlinking = NO and releaseWhenDoneAnimating = NO.

    - (void)release
    {
        if(!isBlinking) {
            [super release];
            return;
        }
    
        releaseWhenDoneAnimating = YES;
    }
    
    - (void) blink {
    
        isBlinking = YES;
    
        if(releaseWhenDoneAnimating) {
            [super release];
            return;
        }
    
        tick++;
    
        if (tick > kNumberOfLights)
            tick = 0;
    
        UIView *lightOne = [self viewWithTag:kLightStartIndex];
        UIView *lightTwo = [self viewWithTag:kLightStartIndex+1];   
    
        [UIView animateWithDuration:0.5
                          delay: 0.0
                        options: UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseOut
                     animations:^{
    
                         if (tick == 0) {
    
                             [lightOne setAlpha:kLightOn];
                             [lightTwo setAlpha:kLightOff];                            
    
                         } else if (tick == 1) {
    
                             [lightOne setAlpha:kLightOff];
                             [lightTwo setAlpha:kLightOn];    
                         }
                     }
                     completion:^(BOOL finished){
                         [self blink];    
                     }];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small AJAX application, written in PHP that I did not secure
I recently did a small jQuery snippet that allows me to show a loading
I did a small web application for using PHP, HTML, and JavaScript. I want
In an Oracle 10 database, I did a small test: SELECT REGEXP_REPLACE('İF', '[Iİ]F', 'DONE',
Did you ever had a bug in your code, you could not resolve? I
Did you ever use Oracle auditing features on a production db? How did that
Did you know that : Map<Object,Object> m1 = new HashMap<Object, Object>(); Map<Object,Object> m2 =
i have some images that get displayed on a page, some of them don't
i did a small ajax div refresh, but instead of replacing the values with
I did a very small app which downloads files from a server. iPhone 4

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.