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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:08:06+00:00 2026-05-26T08:08:06+00:00

I have a class TouchInfo that has an ivar of class MotionStreak. @interface TouchInfo

  • 0

I have a class TouchInfo that has an ivar of class MotionStreak.

@interface TouchInfo : NSObject {
    MotionStreak *streak;
}
...
@end

This class basically handles the touch event and draws a motion streak that follows the touch. I want to release the instance of TouchInfo that associates with a particular touch when the user releases his/her finger, but I want the motion streak to remain for 0.5 to 1.0 second before fading out, so I cannot release the streak ivar in the dealloc method of TouchInfo class.

I’m using timer to delay the release of streak ivar, using a custom timer class as follows:

- (void)dealloc {
    [self timedReleaseStreak];
    [super dealloc];
}

- (void)timedReleaseStreak {
    [streak fadeoutWithDelay:1.0];
    [[TimerHandler sharedTimer] object:streak action:@selector(release) delay:1.0];
}

So far it works without any crashes. But I’m wondering if I’m doing this wrongly, and if there is a better and a recommended way of doing it. Please advice.

p/s: Please, no advice on ARC; I am yet to autorelease the manual reference counting wizardry 😛

  • 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-26T08:08:07+00:00Added an answer on May 26, 2026 at 8:08 am

    Since blocks retain any objects they reference when they get copied, you could implement your animation using them, which will prevent the object from being deallocated until the block is deallocated.

    Here is an example which uses +[UIView animateWithDuration:animations:completion:] to fade the view out and remove it from the view hierarchy. In order to use the completion block later, it has to copy it to the heap, which will result in the view being retained.

    - (void)dealloc {
        UIView *localStreak = streak;
        [UIView animateWithDuration:1.0 animations:^ {
            localStreak.alpha = 0.0;
        } completion:^ (BOOL finished) {
            [localStreak removeFromSuperview];
        }];
        [streak release];
        [super dealloc];
    }
    

    Note that I copied the streak ivar to a local variable, and used that in the block. If you try to use the ivar directly, it will retain self instead, which won’t work because you are already starting the deallocation process.

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

Sidebar

Related Questions

I have class that looks like this: class A { public: class variables_map vm
Basically i have an application for Android 1.5 with a GLSurfaceView class that shows
I have class that extend FragmentActivity in it I add fragment to layout as
I have class grades that I need to check if a specific grade is
I have class like this below shown. which contains the shopping items where the
I bump into this from time to time during class design... when I have
I have this structure: <div class=gBigPage> <span class=gBigMonthShort>FEB</span><br /> <span class=gBigDayShort>23</span><br /> <span class=gBigYearShort>2011</span>
I have Class and Student objects. Both have collection of another as property. Which
I have class LegacyClass which inherits OldBaseClass. I'm considering a change to introduce a
I have class with back reference: public class Employee : Entity { private string

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.