I'm getting this annoying warning: "Assignment makes integer from pointer without a cast". Everytime I test the app, it goes crazy. I have 4 buttons that have text that changes every second. This was working fine, until I changed the way I did it. Now, it ignores the timer and keeps doing it as if in an endless loop with NO pause. Here are my header file declarations:
Code:
NSMutableArray *colors;
NSMutableArray *buttonColors;
NSArray *levelTimes;
NSTimer *timer;
NSTimer *buttonTimer;
NSTimer *buttonTextTimer;
NSString *newColor;
UIAlertView *alerts;
int time;
int timeIndexer;
int currentScore;
int completed;
int totalCompleted;
and my implementation file (where I get the errors):
Code:
timeIndexer = 0;
alerts = [UIAlertView alloc];
totalCompleted = 0;
completed = 0;
currentScore = 0;
currentScoreLabel.text = @"0";
colors = [[NSMutableArray alloc]initWithObjects:@"GREEN",@"YELLOW",@"BLUE",@"RED",nil];
buttonColors = [[NSMutableArray alloc]initWithObjects:[UIColor greenColor], [UIColor yellowColor],[UIColor blueColor],[UIColor redColor],nil];
levelTimes = [[NSArray alloc]initWithObjects:[NSNumber numberWithFloat:3.1],[NSNumber numberWithFloat:2.1],[NSNumber numberWithFloat:1.1],[NSNumber numberWithFloat:0.75],nil];
time = [levelTimes objectAtIndex:timeIndexer];
userInfo = [NSUserDefaults standardUserDefaults];
buttonTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(buttonColorSwitch)
userInfo:nil
repeats:YES];
buttonTextTimer = [NSTimer scheduledTimerWithTimeInterval:timeIndexer
target:self
selector:@selector(buttonTextSwitch)
userInfo:nil
repeats:YES];
// SKIP SOME CODE//
if(completed>=20)
{
[timer invalidate];
timer = nil;
if(time>1)
{
time=time-1;
alerts = [[UIAlertView alloc]initWithTitle:@"Level Up!" message:@"Congrats! You completed 20 levels in a row successfully! You have leveled up and now have 1 less second to complete the challenge!" delegate:self cancelButtonTitle:@"Next level here I come..." otherButtonTitles:nil];
[alerts show];
alerts.tag = 3;
}
else {
timeIndexer++;
time = [levelTimes objectAtIndex:timeIndexer];
alerts = [[UIAlertView alloc]initWithTitle:@"WINNER!" message:@"Congrats! You beat the game and got the highest high score possible!" delegate:self cancelButtonTitle:@"Awesome. Let's do it again!" otherButtonTitles:nil];
[alerts show];
alerts.tag = 4;
}
}
else {
[self updateColor];
}
I skipped most of my code, I just left what was necessary. I found other people having this problem, but it doesn't seem to help. Anyone have any ideas?
Well, this at least is wrong. time is an integer. but objectAtIndex returns a pointer to an object. It is never correct to take a pointer to an object and stick it into an integer variable.
Well, this at least is wrong. time is an integer. but objectAtIndex returns a pointer to an object. It is never correct to take a pointer to an object and stick it into an integer variable.
I figured out that that the line was the problem. So, how do I make an NSArray with FLOATS as the values? (yes, I mean FLOATS!)
I know I would have to change the type of "time" to float.