Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-05-2010, 06:46 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 29
futurevilla216 is on a distinguished road
Exclamation Annoying Warning

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?
futurevilla216 is offline   Reply With Quote
Old 08-05-2010, 06:53 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

See next post.

Last edited by RLScott; 08-05-2010 at 06:57 PM.
RLScott is offline   Reply With Quote
Old 08-05-2010, 06:56 PM   #3 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

Quote:
Originally Posted by futurevilla216 View Post
Code:
  time = [levelTimes objectAtIndex:timeIndexer];
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.
RLScott is offline   Reply With Quote
Old 08-05-2010, 07:20 PM   #4 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 29
futurevilla216 is on a distinguished road
Default

Quote:
Originally Posted by RLScott View Post
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.
futurevilla216 is offline   Reply With Quote
Old 08-05-2010, 07:34 PM   #5 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

Quote:
Originally Posted by futurevilla216 View Post
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!)
You can't. An NSArray can only hold objects. Your choices are:

1. Use NSNumber as the object to hold the float, then extract the float value from these objects using the floatValue method.

2. Use an plain C array of floats.

I would lean toward choice 2, but I don't know what else you may be doing with that code that might make choice 1 better.
RLScott is offline   Reply With Quote
Old 08-07-2010, 06:22 AM   #6 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 29
futurevilla216 is on a distinguished road
Talking

Quote:
Originally Posted by RLScott View Post
You can't. An NSArray can only hold objects. Your choices are:

1. Use NSNumber as the object to hold the float, then extract the float value from these objects using the floatValue method.

2. Use an plain C array of floats.

I would lean toward choice 2, but I don't know what else you may be doing with that code that might make choice 1 better.
Yes, I got it! Thank you so much for the help
futurevilla216 is offline   Reply With Quote
Old 08-07-2010, 06:47 PM   #7 (permalink)
Registered Member
 
Join Date: Sep 2008
Location: London, UK
Posts: 1,050
wuf810 is on a distinguished road
Default

Quote:
Originally Posted by futurevilla216 View Post
Yes, I got it! Thank you so much for the help
and now you would agree that those warnings aren't annoying but there to help you.
wuf810 is offline   Reply With Quote
Old 08-08-2010, 07:32 AM   #8 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 29
futurevilla216 is on a distinguished road
Default

Quote:
Originally Posted by wuf810 View Post
and now you would agree that those warnings aren't annoying but there to help you.
Ya I guess your right
futurevilla216 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 316
10 members and 306 guests
alexP, arash5500, gordo26, HemiMG, mediaspree, nobstudio, Objective Zero, Sloshmonster, stanny, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:26 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0