• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
A Newbie Float Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: A Newbie Float Problem
      • From: Shawn Erickson <email@hidden>
    • Re: A Newbie Float Problem
      • From: Bergmann Manfred <email@hidden>
    • Re: A Newbie Float Problem
      • From: Phil Frost <email@hidden>
  • Prev by Date: Re: WWDC 2005 DVDs [OT]
  • Next by Date: Re: A Newbie Float Problem
  • Previous by thread: Re: Crash in CFStringHash - can I do anything about this?
  • Next by thread: Re: A Newbie Float Problem
  • Index(es):
    • Date
    • Thread