0

I've found a few solutions to others problems around here and elsewhere via Google but no luck with their solutions.

I have a class which controls most of the logic of my flashcard program, and another which controls the view with setters and getters.

Here is the code which interacts with the XIB to change a textfield:

- (void)drawNewQuestion:(NSString*)question :(NSString*)points{
    NSLog(@"DRAWING");
    [_questionView setStringValue:question];
    [_pointsView setStringValue:points];
}

Here is the declaration of the text fields in the .h

@interface MainMenuViewController : NSView{

}

@property (retain)    IBOutlet NSTextField* questionView;
@property (retain) IBOutlet NSTextField* answerView;
@property (retain)    IBOutlet NSTextField* pointsView;

Finally, the XIB has three textviews (as you can see above) which are connected to the above with referencing outlets to File's Owner.

If you need additional code to help me here I will provide it.

Thanks so much for your time, this is just a learning exercise for me so any explanations are welcome.

Dr Ken Reid
  • 577
  • 4
  • 22
  • 1
    assert that _questionView isn't nil ;) -- the code looks fine to me. oh and.. do it on the main thread and then don't block it ether so AppKit can actually reflect your changes on screen – Daij-Djan Jan 11 '14 at 17:26
  • Would a call to the "display"-method help? "[_questionView display];" and "[_pointsView display];" after setting the value. –  Jan 11 '14 at 17:32
  • 1
    think so. but it should happen on main thread too. – Daij-Djan Jan 11 '14 at 17:38
  • it shouldn't be needed though! it is a workaround -- in 99% of the cases you needn't force a redraw – Daij-Djan Jan 11 '14 at 17:39
  • DigiMonk - no luck with that. Thanks for the suggestion. Daij-Djan - It is nil. Do I need to allocate some memory to it or something? – Dr Ken Reid Jan 11 '14 at 18:03
  • 1
    If _questionView is nil, then you probably haven't hooked up the outlet properly, or else the controller where you're logging things is not the same one that you see on screen. If you can, you should post the whole project somewhere. – rdelmar Jan 11 '14 at 21:07

0 Answers0