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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T01:54:44+00:00 2026-05-21T01:54:44+00:00

Alright, so I’m learning programming in Objective-C and Cocoa, and I’ve run into a

  • 0

Alright, so I’m learning programming in Objective-C and Cocoa, and I’ve run into a problem in the project I’m working on. So in my code, I have a NSMutableArray (sources) of objects of a custom class. Each object has a NSString name. I’m trying to get a table view to display all the objects in sources, by the name of each object.

I have the app delegate class following the NSTableViewDataSource protocol, which means having an objectValueForTableColumn method, and a numberOfRowsInTableView method.

In numberOfRowsInTableView, I just have a return [sources count]; statement, and it works fine.

In objectValueForTableColumn, I have return [[sources objectAtIndex: rowIndex] name];, but nothing is displayed.

I have added a lot of NSLog statements for debugging, and I think I know what the problem is, but I don’t know why, or how to fix it.

So, inside objectValueForTableColumn, the sources array is nil. Inside, numberOfRowsInTableView, sources is active, and that method works fine. Now, both these methods run many times, and every time, sources is active in numberOfRowsInTableView, but nil in objectValueForTableColumn.

I replaced the return statement in objectValueForTableColumn with return @”Test string.”;, and it displays the correct number of rows in the table view. Because of this, I know that the table view is set up correctly, besides the problem I am having with sources.

I can’t figure out why sources works in one method, but not the other. I also haven’t found a solution to get my table view working correctly. Any help or insight would be appreciated.

Thanks,
Alex

edit:

- (void) loadFromFile
{
NSString *filePath = @"/Users/alex/opt/Wallify.plist";
NSFileManager *filemgr = [NSFileManager defaultManager];

if ([filemgr fileExistsAtPath: filePath])
{
    NSData *data = [[NSData new] initWithContentsOfFile: filePath];
    NSLog(@"Loaded data from file.");


    self.sources = [NSKeyedUnarchiver unarchiveObjectWithData: data];
    [data release];

    for ( ATImageSource *i in sources)
    {
        NSLog(@"retaining i");
        [i retain];
    }



    [sources retain];


    NSLog(@"&imgsrc: %p", sources);
    NSLog(@"imgsrc: %@", sources);
    NSLog(@"Name: %@",[[sources objectAtIndex: 0] name]);

}
else
{
    //  Saved settings file does not exist
    //  Load defaults

    self.sources = [[NSMutableArray alloc] initWithArray: nil];
    [self.sources retain];

    // new code to setup testfoldersrc
    ATFolderSource *f = [ATFolderSource new];
    f.name = @"Documents";
    f.source = @"/Users/alex/Documents/";
    f.localPath = @"/Users/alex/Documents/";
    f.type = @"f";

    [f populateArrayFromLocalPath];

    [self.sources addObject: f];
    [f release];

    // new code to setup testrsssrc
    ATRSSSource *r = [ATRSSSource new];
    r.name = @"NASA Large Image of the Day";
    r.source = @"http://www.nasa.gov/rss/lg_image_of_the_day.rss";
    r.localPath = @"/Users/alex/opt/nasa_lg_image_of_the_day/";
    r.type = @"r";

    [r getImagesFromRSS];
    [r populateArrayFromLocalPath];

    [self.sources addObject: r];
    [r release];
}

 }
  • 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-21T01:54:45+00:00Added an answer on May 21, 2026 at 1:54 am

    I suspect it’s a race condition in which the array is not populated correctly before NSTableView requests the display data, or something is messing with it in the meantime.

    At any rate, there is probably a better way to do this using an NSArrayController. Apple has a detailed tutorial that can even do sub-arrays of the array (Master/Detail views). It’s mostly some point and click work, and maybe as advanced as an override or two. Check it out at http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaBindings/Tasks/masterdetail.html.

    Using this method should also provide things like sorting and filtering for free, as well as easier maintenance (depending on your viewpoint).

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

Sidebar

Related Questions

Alright, some of you might have noticed I've been working on this problem off
Alright, I'm reading the Aaron Hillegass book for Cocoa Programming, on the drag and
Alright so here it goes, I have my user system working perfectly, and now
Alright. So I figure it's about time I get into unit testing, since everyone's
Alright, currently I have my SWF hitting a php file that will go and
Alright, I have been doing the following (variable names have been changed): FileInputStream fis
Alright. So I have a very large amount of binary data (let's say, 10GB)
Alright, I'm trying to read a comma delimited file and then put that into
Alright. I have a query that looks like this: SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name`
Alright, so I have a query that looks like this: SELECT `orders`.*, GROUP_CONCAT( CONCAT(

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.