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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:16:23+00:00 2026-06-05T11:16:23+00:00

I’m doing a little game in Coco2D and I have a countdown clock Note:

  • 0

I’m doing a little game in Coco2D and I have a countdown clock Note: As I am just trying to fix a bug, I am not working on cleanup so the timer can stop, etc.
Here is my code I’m using to setup the label and start the timer:

timer = [CCLabelTTF labelWithString:@"10.0000" fontName:@"Helvetica" fontSize:20]; 
        timerDisplay = timer;
        timerDisplay.position = ccp(277,310);
        [self addChild:timerDisplay];
        timeLeft = 10;

        timerObject = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(updateTimer) userInfo:nil repeats:YES];

Note: timeLeft is a double

This is updateTimers’s code:

 -(void)updateTimer {
         NSLog(@"Got Called!");

         timeLeft = timeLeft -0.1;
     [timer setString:[NSString stringWithFormat:@"%f",timeLeft]];
       timerDisplay = timer;
         timerDisplay.position = ccp(277,310);
         [self removeChild:timerDisplay cleanup:YES];
         //[self addChild:timerDisplay];  
       if (timeLeft <= 0) {
             [timerObject invalidate];
         }     

     }

When I run this I toggle between crashing on this this:
[timer setString:[NSString stringWithFormat:@"%f",timeLeft]];
and in the green arrow thing it gives Thread 1: EXEC_BAD_ACCESS (code=2, address=0x8)
and
0x197a7ff: movl 16(%edi), %esi and in the green arrow thing it gives Thread 1: EXEC_BAD_ACCESS (code=2, address=0x8)

  • 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-05T11:16:24+00:00Added an answer on June 5, 2026 at 11:16 am

    It looks like your “timer” (not a very good name for a text object IMHO) is being auto-released because it was initialized with a convenience method. So when your timer fires it is likely attempting to manipulate a freed object. There are two ways to fix it: a. alloc and initialize the object yourself, or b. add a “retain” message to it such as:

    [[CCLabelTTF labelWithString:@"10.0000" fontName:@"Helvetica" fontSize:20] retain]; 
    

    In both cases you will then be responsible to release the object in your dealloc or similar method when you are done with it:

    [timer release];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.