Results 1 to 2 of 2
  1. #1

    Member Since
    Oct 22, 2009
    Basic Problem reading input from NSTextCell in Xcode
    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;



  2. #2

    Member Since
    May 03, 2009
    MBP 2.33 4GB: MacPro 8 Core 2.8, 16GB: MacMini 2.26 4GB: MacMin 2.53 4GB: iPhone3GS 32GB
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. New to Xcode and mac development, need basic help
    By drumvudu in forum OS X - Development and Darwin
    Replies: 3
    Last Post: 07-19-2014, 09:33 PM
  2. Basic info on Xcode compilers (C++)
    By Annettest in forum OS X - Operating System
    Replies: 10
    Last Post: 08-03-2010, 04:51 PM
  3. Need help working with basic C in xcode
    By DB_KG in forum OS X - Development and Darwin
    Replies: 3
    Last Post: 08-07-2009, 11:23 PM
  4. Programming basic C in Xcode
    By DrQuincy in forum OS X - Development and Darwin
    Replies: 4
    Last Post: 01-16-2008, 04:22 PM
  5. Basic composite video input box?
    By Itbepopples in forum Other Hardware and Peripherals
    Replies: 3
    Last Post: 12-27-2006, 12:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts