New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

Start a Discussion

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Basic Problem reading input from NSTextCell in Xcode

Post Reply New Thread Subscribe

Thread Tools

Member Since: Oct 22, 2009
Posts: 1
Alex_Rutherford is on a distinguished road

Alex_Rutherford is offline
Hi, I'm new to Objective C and just doing some basics.

All I want to do is;

- read a value from one text field
- double it
- output it to another text field

But I'm stuck on the first, each time I try to read the value in it returns a value of 0 even though the entry is clearly 1 or 3 or 100.

This is the snippet

input=[inputfield floatValue];

Where inputfield is the NSTextCell box and input is a float.

The rest of the code is below in case it is useful.

Please help, going insane!

************************************************** *****

#import "readandwrite.h"

@implementation readandwrite

@synthesize input, output;

-(IBAction)calculate: (id) sender

// float input;

input=[inputfield floatValue];
printf("Input is %f\n",input);
printf("Output is %f\n",output);
[outputfield setFloatValueutput];


************************************************** *****

#import <Cocoa/Cocoa.h>

@interface readandwrite : NSObject {
char input;
float output;
IBOutlet NSTextField *outputfield;
IBOutlet NSTextField *inputfield;


@property(readwrite) float output;
@property(readwrite) char input;


QUOTE Thanks

Member Since: May 02, 2009
Posts: 480
wmprice1240 has a spectacular aura about
Mac Specs: MBP 2.33 4GB: MacPro 8 Core 2.8, 16GB: MacMini 2.26 4GB: MacMin 2.53 4GB: iPhone3GS 32GB

wmprice1240 is offline
Hi, welcome to the forums.

I was able to compile and run your code (with a few stylistic modifications) with no issues. I assume you have your outlets and actions correctly setup via InterfaceBuilder and that the calculate message is actually being invoked. Is this correct? I assume your using a simple button control to send the readandwrite target the action and that the connection is made via InterfaceBuilder as well.
QUOTE Thanks

Post Reply New Thread Subscribe

« Does anyone have Interface Builder UserGuide for Leopard? | Interface Builder Noob »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
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 Off
Forum Jump

Similar Threads
Thread Starter
Last Post
Anyone know the basic code difference between VS and XCode? SapAuthor OS X - Development and Darwin 2 09-28-2009 02:18 PM
Need help working with basic C in xcode DB_KG OS X - Development and Darwin 3 08-07-2009 10:23 PM
Help!! Incredibly basic Xcode Tools Question pdcom OS X - Development and Darwin 1 08-26-2008 03:40 PM
Programming basic C in Xcode DrQuincy OS X - Development and Darwin 4 01-16-2008 03:22 PM
Basic composite video input box? Itbepopples Other Hardware and Peripherals 3 12-26-2006 11:01 PM

All times are GMT -4. The time now is 11:30 PM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.

Welcome to

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!

(4 digit year)

Already a member?