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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:32:32+00:00 2026-06-16T23:32:32+00:00

I have a NSTableview with three columns ‘Thumbnail’,’FileName’ and ‘Datemodified’. The file name column

  • 0

I have a NSTableview with three columns ‘Thumbnail’,’FileName’ and ‘Datemodified’. The file name column and date modified column is filled with the output of S3ListObjectResponse. While the ‘Thumbnail’ column image is loaded from the local directory of the machine. If the file is missing, I download it from the S3 cloud. The problem is how to insert the data into the NSArrayController if the file is missing and I’m left with an empty cell for the thumbnail? Here is my work as of now :

- (IBAction)checkCloud:(id)sender {
AmazonS3Client *s3 = [AmazonClientManager s3];

S3ListObjectsRequest* listObjectsRequest = [[S3ListObjectsRequest alloc] initWithName:@"hello-testing"];



NSRange range = NSMakeRange(0, [[_fileListAC arrangedObjects] count]);
[_fileListAC removeObjectsAtArrangedObjectIndexes:[NSIndexSet indexSetWithIndexesInRange:range]];

@try {


    S3ListObjectsResponse* response = [s3 listObjects:listObjectsRequest];

    NSMutableArray* objectSummaries = response.listObjectsResult.objectSummaries;

    //looping through the objSummary and add into the NSArrayController
    for ( S3ObjectSummary* objSummary in objectSummaries ) {

        NSImage *thumbnail = [[NSImage alloc] init ];


        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];


        [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"];

        NSDate *s3date = [dateFormatter dateFromString:[objSummary lastModified]];


        NSArray *fileName =  [[objSummary key] componentsSeparatedByString:@"/"];
        if([[fileName objectAtIndex:0] localizedCaseInsensitiveCompare:@"Range"] == NSOrderedSame) {
            NSLog(@"file name %@ ",[fileName objectAtIndex:1]);

           // Check for files in side the bucket's folders 
           if([[fileName objectAtIndex:1] length]){

                NSString *thumbnailFile = [[fileName objectAtIndex:1] stringByAppendingString:@"_thumb.png"];


                BOOL isDir;

                NSFileManager *fileManager = [NSFileManager defaultManager];

                NSString *filePathPart1 = [@"/Users/" stringByAppendingString:[[NSHost currentHost] localizedName]];

                NSString *filePath = [[[[ filePathPart1 stringByAppendingString:@"/Documents/Test/" ] stringByAppendingString:@"Range" ] stringByAppendingString:@"/Thumbnail/"] stringByAppendingString:thumbnailFile];


               // If file exists then add into the thumbnail column
               if([fileManager fileExistsAtPath:filePath isDirectory:&isDir]){

                    thumbnail = [[NSImage alloc] initWithContentsOfFile:filePath];



                }else{

                     NSLog(@"file %@ not found",thumbnailFile);


                    //Downloading from the S3 Cloud Asynchronously

                    doneDownload = NO;
                    AmazonS3Client *s3 = [AmazonClientManager s3];
                    S3GetObjectRequest *gor = nil;
                    @try {

                        gor = [[S3GetObjectRequest alloc] initWithKey:[[@"Range/Thumbnail/"  stringByAppendingString:[fileName objectAtIndex:1]] stringByAppendingString: @"_thumb"] withBucket:@"thumbnail-pic" ];
                        gor.delegate = self;
                        [s3 getObject:gor];
                    }
                    @catch (AmazonClientException *exception) {
                        doneDownload = YES;
                    }

                    do {
                        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
                    } while (!doneDownload);
                    gor.delegate = nil;

                }

            }else{
                //If its the actual bucket folder and not file then load a default image 
                thumbnail = [NSImage imageNamed:@"Range.png"];
            }

        }

           [_fileListAC addObject:[NSMutableDictionary  dictionaryWithObjectsAndKeys:thumbnail,@"thumbnail", [objSummary key],@"Files",s3Date,@"Date Modified", nil]];





    }
}
@catch (NSException *exception) {
    NSLog(@"Cannot list S3 %@",exception);
}

//Display the table on loading the NSArrayController
[_cloudFileList makeKeyAndOrderFront:nil]; 

}

I have checked the delegate method

 -(void)request:(AmazonServiceRequest *)request didCompleteWithResponse:(AmazonServiceResponse *)response{
NSData *imageData = [response body];
_coreDataImageView.image = [[NSImage alloc] initWithData:imageData];
doneDownload = YES;
}

coredataimageview is a test image well. The image is downloaded but I want to add it back to the array controller. Issue is what if I have 3 file missing from the local directory and I’m unable to insert into array controller for that file name and date modified values. Any help on this?

  • 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-16T23:32:33+00:00Added an answer on June 16, 2026 at 11:32 pm

    If you implement a delegate object (rather than using self) you could store these objects in an array and reference them later. The delegate object could track the additional pieces of metadata you are interested in and could be used to construct your table view.

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

Sidebar

Related Questions

I have a problem with sorting NSTableColumn contents. In my NSTableView there are three
I have NSTableView with two columns, and i wanna fill them entries from SQLite
I have a NSTableView with two columns, one is NSButtonCell and the other is
I have a NSTableView that holds a name to all of my NSImageView's, and
I have an NSTableView that contains a few columns that are populated with data.
I have a NSTableView with multiple columns. clicking each of the columns sorts by
I have a view with a nssearchfield a nstableview and a nsmatrix with three
I have a custom NSTableView subclass filled with several custom NSTextFieldCell subclasses. I would
I have a NSTableView with 3 columns. I can sort using any of the
I have a view-based NSTableView that usually has one column in it. However, at

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.