I need help with XCODE

Discussion in 'iOS Programming' started by TonyTokyo, May 14, 2011.

  1. TonyTokyo, May 14, 2011
    Last edited by a moderator: May 15, 2011

    macrumors newbie

    Joined:
    May 14, 2011
    #1
    I need help with tis code I m getting error message,

    here is the error message.

    code here
    Code:
    [NSTimer scheduledTimerWithTimeInterval:1.0/60 target:self selector:@selector(gameloop) userinfo:nil repeats:YES]; 
    with error message- NSTimer may not respond to '+scheduledTimerWithTimeInterval:target:selector:userinfo:repeat:'


    Here is the whole code that I was working on
    cheers





    Code:
    #import "gameViewController.h"
    
    
    
    #define kStateRunning 1
    
    #define kStateGameOver 2
    
    
    
    #define kGravity 0.195
    
    
    
    @implementation gameViewController
    
    @synthesize bg, ball, platform1, platform2, platform3, platform4, platform5;
    
    @synthesize gameState;
    
    @synthesize ballVelocity, gravity;
    
    
    
    //Implement viewDidLoad to do additional setup after loading the view,typically from a nib.
    
    - (void)viewDidLoad {
    
    	[super viewDidLoad];
    
    	gameState = kStateRunning;
    
    	ballVelocity = CGPointMake(0, 0);
    
    	gravity =CGPointMake(0, kGravity);
    
    
    
    	[NSTimer scheduledTimerWithTimeInterval:1.0/60 target:self selector:@selector(gameloop) userinfo:nil repeats:YES];
    
    }
    
    
    
    - (void)gameloop {
    
    	if (gameState == kStateRunning)
    
    	{
    
    		[self gameStatePlayNormal];
    
    	}
    
    	else if (gameState == kStateGameOver)
    
    	{
    
    	
    
    	}
    
    }
    
    
    
    - (void)gameStatePlayNormal {
    
    	ballVelocity.y += gravity.y;
    
    	
    
    	ball.center = CGPointMake(ball.center.x + ballVelocity.x,ball.center.y + ballVelocity.y);
    
    }
    
    	
    
    /*
    
    // The designated initializer. Override to perform setup that is required before the view is loaded.
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    
        if (self) {
    
            // Custom initialization
    
        }
    
        return self;
    
    }
    
    */
    
    
    
    /*
    
    // Implement loadView to create a view hierarchy programmatically, without using a nib.
    
    - (void)loadView {
    
    }
    
    */
    
    
    
    
    
    /*
    
    // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
    
    - (void)viewDidLoad {
    
        [super viewDidLoad];
    
    }
    
    */
    
    
    
    
    
    /*
    
    // Override to allow orientations other than the default portrait orientation.
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    
        // Return YES for supported orientations
    
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    
    }
    
    */
    
    
    
    ;- (void)didReceiveMemoryWarning {
    
    	// Releases the view if it doesn't have a superview.
    
        [super didReceiveMemoryWarning];
    
    	
    
    	// Release any cached data, images, etc that aren't in use.
    
    }
    
    
    
    - (void)viewDidUnload {
    
    	// Release any retained subviews of the main view.
    
    	// e.g. self.myOutlet = nil;
    
    	self.bg = nil;
    
    	self.ball = nil;
    
    	self.platform1 = nil;
    
    	self.platform2 = nil;
    
    	self.platform3 = nil;
    
    	self.platform4 = nil;
    
    	self.platform5 = nil;
    
    }
    
    
    
    
    
    - (void)dealloc {
    
        [super dealloc];
    
    	[bg release];
    
    	[ball release];
    
    	[platform1 release];
    
    	[platform2 release];
    
    	[platform3 release];
    
    	[platform4 release];
    
    	[platform5 release];
    
    }
    
    @end
     
  2. macrumors G5

    gnasher729

    Joined:
    Nov 25, 2005
    #2
    Of course it doesn't work. And it says right there what is wrong.

    You don't need help with XCode, you need help with spelling. Look at the selector _carefully_. Then look at the methods in NSTimer _carefully_. You may think there is a method named '+scheduledTimerWithTimeInterval:target:selector:userinfo:repeat:', but there isn't.
     

Share This Page