Results 1 to 2 of 2
Thread: Newbie problem with NSTextField
-
07-04-2013, 07:42 AM #1
- Member Since
- Jul 04, 2013
- Posts
- 1
Newbie problem with NSTextFieldI 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]; }
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
Any help would be greatly appreciated.
-
07-06-2013, 03:07 PM #2
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.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
newbie office problem
By mazza77 in forum Switcher HangoutReplies: 5Last Post: 07-24-2011, 04:18 AM -
NSTextField doesnt change textColor
By VaStO in forum macOS - Development and DarwinReplies: 8Last Post: 10-03-2010, 05:46 PM -
newbie router problem
By mrback in forum Internet, Networking, and WirelessReplies: 1Last Post: 05-24-2007, 06:56 PM -
newbie imac problem
By n_hendrick in forum Apple DesktopsReplies: 3Last Post: 11-14-2006, 08:42 AM -
newbie problem..
By Jon in forum Switcher HangoutReplies: 22Last Post: 08-11-2003, 07:45 PM