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 8160119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:08:37+00:00 2026-06-06T18:08:37+00:00

I’m quite new to Cocoa and I am trying to setup a table view

  • 0

I’m quite new to Cocoa and I am trying to setup a table view backed by an array. I’ve setup the app delegate as the datasource for the tableview, and implemented NSTableViewDataSource protocol.

When I run the app, I get the following log output:

2012-06-23 18:25:17.312 HelloWorldDesktop[315:903] to do list is nil
2012-06-23 18:25:17.314 HelloWorldDesktop[315:903] Number of rows is 0
2012-06-23 18:25:17.427 HelloWorldDesktop[315:903] App did finish
launching

I thought that when I called reloadData on the tableView it would call numberOfRowsInTableView:(NSTableView *)tableView again to refresh the view, but that doesn’t seem to be happening. What have I missed?

My .h and .m listings are below.

AppDelegate.h

#import <Cocoa/Cocoa.h>

@interface AppDelegate : NSObject <NSApplicationDelegate, NSTableViewDataSource> 

@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet NSTableView * toDoListTableView;

@property (assign) NSArray * toDoList;

@end

AppDelegate.m

#import "AppDelegate.h"

@implementation AppDelegate 

@synthesize window = _window;
@synthesize toDoList; 
@synthesize toDoListTableView;

- (void)dealloc
{
    [self.toDoList dealloc];
    [super dealloc];
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    NSLog(@"App did finish launching");
    // Insert code here to initialize your application
  //  toDoList = [[NSMutableArray alloc] init];
    toDoList = [[NSMutableArray alloc] initWithObjects:@"item 1", @"item 2", nil];
    [self.toDoListTableView reloadData];
   // NSLog(@"table view %@", self.toDoListTableView);

}

//check toDoList initialised before we try and return the size
- (NSInteger) numberOfRowsInTableView:(NSTableView *)tableView {
    NSInteger count = 0;
    if(self.toDoList){
        count = [toDoList count];
    } else{
        NSLog(@"to do list is nil");
    }
    NSLog(@"Number of rows is %ld", count);
    return count;
}

-(id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
    NSLog(@"in objectValueForTable");
    id returnVal = nil;

    NSString * colId = [tableColumn identifier];

    NSString * item = [self.toDoList objectAtIndex:row];

    if([colId isEqualToString:@"toDoCol"]){
        returnVal = item;
    } 

    return returnVal;

}

@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-06-06T18:08:38+00:00Added an answer on June 6, 2026 at 6:08 pm

    The first thing that I’d check is that you’re NSTableView IBOutlet is still set in applicationDidFinishLaunching.

    NSLog(@"self.toDoListTableView: %@", self.toDoListTableView)
    

    You should see output like:

    <NSTableView: 0x178941a60>
    

    if the outlet is set properly.

    If you see ‘nil’ rather than an object, double check to ensure that your NSTableView is connected to your outlet in the XIB editing mode of Xcode. Here’s a documentation link for assistance connecting outlets.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;

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.