A Newbie Float Problem
A Newbie Float Problem
- Subject: A Newbie Float Problem
- From: Jonathan Faulkenberry <email@hidden>
- Date: Thu, 15 Dec 2005 22:09:11 -0500
Hi all,
I am relatively new to Cocoa, although I have some experience with
some basic C. For some reason though, I am having trouble creating a
small app I am using to help me learn Cocoa. This app is supposed to
hold a float value named "money" an have two buttons, one which will
call addMoney: (which will add 5 to the float value) and one called
drink: (which will decrease the float value by 5). For some reason,
when I click on the button that calls addMoney:, the value of the
float goes to like a 10 digit number. I am almost positive I have
everything right in my header file and nib, so I'm guessing it is
something in my .m file. Here is the code: (I haven't finished all of
the methods yet since the float won't work right). Any help would
greatly appreciated. Thanks in advance.
#import "AppController.h"
@implementation AppController
- (id) init {
self = [super init];
if (self != nil) {
money = 0.00;
NSLog(@"init");
NSLog(@"Money = %d", money);
}
return self;
}
- (void) awakeFromNib
{
[textField setStringValue:[NSString stringWithFormat:@"%d", money]];
}
- (IBAction)addMoney:(id)sender
{
money = money + 5;
NSLog(@"Money = %d", money);
}
- (IBAction)drink:(id)sender
{
}
- (float)money
{
return money;
}
- (void) dealloc
{
[super dealloc];
}
@end
Jonathan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden