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

The Archive Base Latest Questions

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

here is an absolute brain destroyer: NOTE: I am using XCode 4.2 with iOS

  • 0

here is an absolute brain destroyer:

NOTE: I am using XCode 4.2 with iOS 5 and ARC (Automatic Reference Counting)

If anybody can help explain why none of my variables are retaining their value I will be grateful beyond reason. Currently I have this int variable speed. Heres the basic code rundown:

In Header File:

@interface GameLoop : NSObject {
   CADisplayLink *refresh;

   int speed;
}

In .m File:

- (void)awakeFromNib {
   screenRefresh = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateGame:)];
   [screenRefresh setFrameInterval:1];
   [screenRefresh addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; 
}

- (void)createNewGame {
   speed = 4;
}

- (void)updateGame:(CADisplayLink *)gameTime {
   [factory slideViews:speed];  // <---- Speed ALWAYS equals 0
}

The factory class simply moves stuff around. If I plug in 4 in place of speed everything works perfectly. I have also tried making speed by:

@property (nonatomic, assign) int speed;

And synthesising and using self.speed. If anyone can help, I would be very thankful! I’m sure it’s something simple, but just the fact that I assign in one method and it doesn’t follow through in another drives me insane. I also have used NSLog("%d", speed) and it spits out the correct value in the method I assign it in, and when I re-call it before assigning.

Update
After a little debugging, it appears as though once the timer is created, no global variables are updated within the update loop. If I make speed = 4 before allocating the CADisplayLink, the game runs at 4. However even if I make proper changes to speed it does not change. Anybody know why?

  • 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-25T14:26:54+00:00Added an answer on May 25, 2026 at 2:26 pm

    Okay, so the problem had to do with something larger than the context of which I originally thought it was on. The problem was that I wasn’t properly allocating things into memory, and because of that I was assigning to nil variables.

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

Sidebar

Related Questions

I'm an absolute Silverlight noob that is confused by the help file. Here is
I hava a java program with a JFrame I am using absolute positioning here
Here's my current layout achieved using absolute/relative positioning: http://jsfiddle.net/keruilin/xB8Bt/50/ To make a long story
Canvas with absolute position doesn't work as you can see here: http://jsfiddle.net/733zs/1/ (Tested in
Here is a lisp procedure that simply adds 'a' to the absolute value of
This is related to my previous question here . I want 4 divs (absolute
Ok, here goes. I've completed a Cocoa foundation-tool that calculates mean absolute deviation of
Here's the HTML <div class=panel id=Panel1> <fieldset style=position: absolute; top:8px; left: 136px; width: 136px;
Here is my code http://jsfiddle.net/AB6J3/7/ you can see, edit, etc. When I roll over
Here is my code: <div class='some' style='position: absolute; left: 300; top: 300;'>..</div> It parses

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.