0

I'm very new to Xcode. All I want to do is output the string to the NSTextField. It does output exactly what I want to the console. (e.g http://myserver.test.com

I need to to output to the NSTextField.

Any help?

My .h file

#import <Cocoa/Cocoa.h>
@interface ViewController : NSViewController
@property (weak) IBOutlet NSTextField *serverurl;
- (IBAction)sendit:(id)sender;
@end

My .m file

#import "ViewController.h"

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Do any additional setup after loading the view.
    NSString *plistPath = @"/Library/Preferences/test.plist";
    NSDictionary *plistData = [NSDictionary dictionaryWithContentsOfFile:plistPath];
    NSString *item = [plistData valueForKeyPath:@"URL"];
    NSLog(@"%@", [NSString stringWithFormat:@"%@", item]);
}

@end
rmaddy
  • 314,917
  • 42
  • 532
  • 579
user2720970
  • 284
  • 1
  • 3
  • 17
  • What have you tried? I see that you have an outlet to an NSTextField but I don't see you trying to do anything with it. – matt Aug 22 '17 at 16:31
  • myTextField.stringValue = @"item" https://stackoverflow.com/questions/2841559/how-do-you-set-the-text-in-an-nstextfield – Johnny Rockex Aug 22 '17 at 16:50

1 Answers1

0

My Objective-C is a bit rusty but you just need to set the value that you are passing to NSLog into the textfield:

serverurl.stringValue = item;
Abizern
  • 146,289
  • 39
  • 203
  • 257