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.

Newbie problem with NSTextField


Post Reply New Thread Subscribe

 
Thread Tools
Pengwin

 
Member Since: Jul 04, 2013
Posts: 1
Pengwin is on a distinguished road

Pengwin is offline
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:
Code:
-(IBAction)doAdd:(id)sender
{
    if(!vapingController)
    {
        vapingController = [[kp_VapingSpendController alloc] initWithWindowNibName:@"Add Vaping Spend"];
    }
    [vapingController showWindow:self];
}
whilst in the kp_VapingController, I currently have the following code:

Code:
@interface kp_VapingSpendController ()

@end

@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"];
}

@end
Neither the NSTextField spent, nor the windows title are being updated.

Any help would be greatly appreciated.
QUOTE Thanks
Mark FX

 
Mark FX's Avatar
 
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 169
Mark FX has a spectacular aura about

Mark FX is offline
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
snippet.

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.
QUOTE Thanks

Post Reply New Thread Subscribe


« Costs and requirements to support OSX | Visual Studio Expert. »
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
Thread Starter
Forum
Replies
Last Post
Yet Another WiFi Signal Problem Question PGB1 Internet, Networking, and Wireless 8 03-24-2013 07:30 AM
iPhone onscreen volume control problem smuggerific iOS and Apps 1 04-19-2010 10:18 AM
newbie to forum, have a problem with my Mini? Chertin Apple Desktops 3 04-04-2010 04:52 PM
Huge Graphics Problem With Magic Garage Band mattcooper87 OS X - Apps and Games 0 08-21-2007 08:23 AM
newbie problem.. Jon Switcher Hangout 22 08-11-2003 07:45 PM

All times are GMT -4. The time now is 01:01 AM.

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

Welcome to Mac-Forums.com

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?