Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Furtim

macrumors member
Original poster
Jul 8, 2008
37
0
#import "AppController.h"

@implementation AppController
- (IBAction)Calculate:(id)sender {
if (Fiber >= 4){

Fiber = 4;
}
Points = ( Calories / 50 ) + ( Fat / 12 ) - ( Fiber / 5 );
}
@end

I'm trying to make a Weight Watchers calculator and I keep coming up with errors. I'm not sure what I'm doing wrong....

I'm getting errors after if (Fiber >= 4){ saying warning: comparison between pointer and integer

Also getting errors after Fiber = 4; saying warning: assignment makes pointer from integer without a cast

And last errors after Points = ( Calories / 50 ) + ( Fat / 12 ) - ( Fiber / 5 ); saying error: invalid operands to binary /

Any help would be grateful. Thank you.
 
from the warnings and errors, I'd say Fiber is declared as a int * instead of int. If it is a pointer and needs to be you need to dereference Fiber before using its value in an expression.

-Lee
 
Fiber, Points, etc are what the textfields are called under outlets...not sure if that answers your question.
 
Okay, I understood what you meant I got now...

#import "AppController.h"

@implementation AppController
- (IBAction)Calculate:(id)sender {
double iCal, iFat, iFiber, iPoints;
iCal = [Calories doubleValue];
iFat = [Fat doubleValue];
iFiber = [Fiber doubleValue];
if (iFiber > 4)
iFiber = 4;
iPoints = (Calories / 50) + (Fat / 12) - (Fiber / 5);
}
@end

Everything runs fine except I get an error for the iPoints = (Calories / 50) + (Fat / 12) - (Fiber / 5); line
 
Assignment makes integer from pointer without a cast

Hi,
In Objective-c, I have one function which accepts int as parameter, viz:
-(void)Sum:(int)i{
Sum = i+10;
}

where 'Sum' is static variable declared globally, int he same .m file.
now, I am calling this 'Sum' function from some other function as follows:
-(void)Funct{
int i = 10;
[self Sum:i];
}

After **[self Sum:i];** i get warning saying:
"assignment makes integer from pointer without a cast"


I am not getting where is the mistake. Please let me know as soon as possible.

Thanx.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.