Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6616823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:37:46+00:00 2026-05-25T20:37:46+00:00

I trying to learn Xcode, Cocoa, Objective C. Today I thought I was going

  • 0

I trying to learn Xcode, Cocoa, Objective C. Today I thought I was going to make a simple app the uses the Nac file browser, reads the file and displays it in an NSTevtView.

Everything acts like it wants to work but the file never displays. If I debug it, it shows my string has the file contents but I can’t get it to display to the TextView.

Here is my code, OpenUp.h and OpenUp.m

#import <Foundation/Foundation.h>

@interface OpenUp : NSObject

{

   NSString *reader;
   IBOutlet NSTextField *mainField;
}

@property(readwrite,copy)NSString *reader;

- (void)awakeFromNib;
- (IBAction)openExistingDocument:(id)sender;

@end


//OpenIt.m

#import "OpenUp.h"

@implementation OpenUp

@synthesize reader;


- (id)init
{
self = [super init];
if (self) {
    // Initialization code here.

    }

    return self;
}

- (IBAction)openExistingDocument:(id)sender{

    NSOpenPanel* panel = [NSOpenPanel openPanel];

    [panel retain];


    // This method displays the panel and returns immediately.

    // The completion handler is called when the user selects an

    // item or cancels the panel.

    [panel beginWithCompletionHandler:^(NSInteger result){

        if (result == NSFileHandlingPanelOKButton) {

            NSURL*  theDoc = [[panel URLs] objectAtIndex:0];
            NSLog(@"%@", theDoc);

            //open the document

           NSError *error;
            self.reader = [[NSString alloc] initWithContentsOfURL: theDoc encoding:NSUTF8StringEncoding error:&error];
            NSLog(@"%@",error);


        }
          // Balance the earlier retain call.

        [panel release];

    }];

    [mainField setStringValue: self.reader];//this should display the contents of the string


    }
    - (void)awakeFromNib {
        self.reader = @"";//initialize reader 
    }

    @end

I’m not sure if I’m doing something wrong with memory allocation, or if a string read from a file won’t use this windows. I’ve tried both the NSScrollViewer and the NSTextField
Everything compiles and acts like it wants to work it just wont display the string.

Any help is very much appreciated.
Mike

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:37:47+00:00Added an answer on May 25, 2026 at 8:37 pm

    Make sure the IBOutlet is actually connected in the XIB. Try logging its value after you set its string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to learn Objective-C for xcode. I was wondering if there was an
If I am messing around with XCode and trying to learn Objective-C, does it
Objective-c is learn-able; Cocoa is learn-able; I find Interface Builder and its descendant Xcode
I'm trying to learn objective-c by making a GUI application using Xcode 3. I'm
Trying to learn a bit about PDO and is going through this tutorial .
Trying to learn about php's arrays today. I have a set of arrays like
I've been trying to learn the new Storyboard feature in Xcode and I've run
I am trying to learn the basic of 3d for Mac using Xcode, so
I'm trying to learn to create and use static libraries in my Xcode projects
Trying to learn C++ and working through a simple exercise on arrays. Basically, I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.