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

  • SEARCH
  • Home
  • 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 756413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:14:31+00:00 2026-05-14T15:14:31+00:00

I’m making a simple to-do-list project and running into a few bumps in the

  • 0

I’m making a “simple” to-do-list project and running into a few bumps in the road. The problem is that my NSTableView is NOT showing the data from the NSMutableArray “myArray” and I don’t know why that is. Can someone point out my mistake?

/*
 IBOutlet NSTextField *textField;
 IBOutlet NSTabView *tableView;
 IBOutlet NSButton *button;
 NSMutableArray *myArray;
 */

#import "AppController.h"


@implementation AppController


-(IBAction)addNewItem:(id)sender
{

    NSString *myString = [textField stringValue];

    NSLog(@"my stirng is %@",myString);
    myArray = [[NSMutableArray alloc] initWithCapacity:100];
    [myArray addObject:myString];

}

- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
    return [myArray count];
}
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
            row:(int)rowIndex
{

    return [myArray objectAtIndex:rowIndex];
}

-(id)init
{
    [super init];
    [tableView setDataSource:self];
    [tableView setDelegate:self];

    NSLog(@"init");
    return self;
}

@end
  • 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-14T15:14:31+00:00Added an answer on May 14, 2026 at 3:14 pm

    The problem is that in your -init method, your tableView variable will still be nil. When a nib file is loaded, it first creates and initializes all the objects declared in the nib and only then sets up the connections (outlets, bindings, actions) between them. Any initialization code of yours that depends on the various actions, outlets or bindings being set up needs to be placed in the -(void)awakeFromNib method not the -init method. You can also set the dataSource and delegate outlets of your table view right in Interface Builder, just by control-dragging from the tableView to your AppController in the main nib window, and choosing each outlet in turn.

    Also, whenever you change your underlying data, you need to call [tableView reloadData] to get the tableView to reflect those changes. In you case, you’d need to call it in your -addNewItem: method. So, your code should look something like this:

    @implementation AppController
    - (id)init
    {
        if (nil == (self = [super init])) return nil;
        myArray = [[NSMutableArray alloc] init];
        return self;
    }
    - (void)dealloc
    {
        [myArray release];
        [super dealloc];
    }
    - (void)awakeFromNib
    {
        // assuming you're not just setting up these outlets in IB
        [tableView setDataSource:self];
        [tableView setDelegate:self];
    }
    -(IBAction)addNewItem:(id)sender
    {
        [myArray addObject:[textField stringValue]];
        [tableView reloadData];
    }
    // data source methods same as in your code
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.