Results 1 to 2 of 2

Thread: Newbie problem with NSTextField

  1. #1

    Member Since
    Jul 04, 2013
    Newbie problem with NSTextField
    I am working on my forst Cocoa project and have come up against a strange problem I cannot solve.
    This app is a small menu bar application, with a menu and 2 dialogs.
    Then the dialogs are shown, some data is displayed, however, for some reason, the NSTextfields, in fact none of the controls are being updated.

    The main delegate have this method to show the window:
            vapingController = [[kp_VapingSpendController alloc] initWithWindowNibName:@"Add Vaping Spend"];
        [vapingController showWindow:self];
    whilst in the kp_VapingController, I currently have the following code:

    @interface kp_VapingSpendController ()
    @implementation kp_VapingSpendController
    - (id)initWithWindow:(NSWindow *)window
        self = [super initWithWindow:window];
        if (self) {
            // Initialization code here.
        return self;
    - (void)windowDidLoad
        [super windowDidLoad];
        // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
        [spent setStringValue:@"0.00"];
        [[self window] setTitle:@"Test"];
    Neither the NSTextField spent, nor the windows title are being updated.

    Any help would be greatly appreciated.

  2. #2

    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    West Sussex, UK
    Firstly you are initializing the vapingController instance vaiable with the kp_VapingSpendController's
    initWithWindowNibName, but you're implementation of the kp_VapingSpendController does not
    implement the initWithWindowNibName method, it only shows the initWithWindow method in you're code

    Secondly you've not shown the public interface for the kp_VapingSpendController class, only the private
    interface, so we cant see if you've placed an IBOutlet to the TextField.
    Also I suspect you've not set up the window connection in Interface Builder, to you're window controller.

    When naming objects like NSTextField's, it's good practice to name them so other programmers can
    understand what they are, the name "spent" sounds more like a variable than a UI object, so I would name
    you\re textField something like "spentTextField", that way it's more clear to yourself and others what it is.

    Check that you have connections to any UI objects that you wish to manipulate, set up in the public
    interface as IBOutlet's.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. newbie office problem
    By mazza77 in forum Switcher Hangout
    Replies: 5
    Last Post: 07-24-2011, 04:18 AM
  2. NSTextField doesnt change textColor
    By VaStO in forum macOS - Development and Darwin
    Replies: 8
    Last Post: 10-03-2010, 05:46 PM
  3. newbie router problem
    By mrback in forum Internet, Networking, and Wireless
    Replies: 1
    Last Post: 05-24-2007, 06:56 PM
  4. newbie imac problem
    By n_hendrick in forum Apple Desktops
    Replies: 3
    Last Post: 11-14-2006, 09:42 AM
  5. newbie problem..
    By Jon in forum Switcher Hangout
    Replies: 22
    Last Post: 08-11-2003, 07:45 PM

Posting Permissions

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